Ask your WordPress questions! Pay money and get answers fast! (more info)

WP Super Cache certain Query Strings URL WordPress

  • SOLVED

WP Super Cache plugin only wp-cache URLs with query strings but does not super cache. See attached screenshot.

There is a difference between WP-Cache and Super Cache which is WP-Cache still invokes PHP while Super Cache bypasses everything and simply serves a static HTML file for fastest performance. There is an explanation about this at the 2nd and 3rd paragraph.
http://ocaoimh.ie/wp-super-cache/

I would like to super cache a specific URL type with query string which is:
http://www.raymond.cc/blog/download/?did=XX (Replace XX with incremental numbers)

Thanks.

Answers (3)

2013-11-11

Dbranes answers:

Hey Raymond, have you tried the other way round, to rewrite the url to get rid of
the GET parameter?

http://www.raymond.cc/blog/download/did/19 => http://www.raymond.cc/blog/download/?did=19


where the rewrite rule would be something like:

RewriteRule ^blog/download/did/([^/]*)$ /blog/download/?did=$1 [L]


You can also consider

function custom_endpoint()
{
add_rewrite_endpoint( 'did', EP_PAGES );

}
add_action( 'init', 'custom_endpoint' );


or something like this

function custom_rewrite()
{
// you can adjust this to your needs:
add_rewrite_rule('/download/did/([^/]*)/?','index.php?name=download&did=matches[1]','top');
}
add_action( 'init', 'custom_rewrite' );


if your page name is <em>download</em>.

Then to access the <em>did</em> variable in your template, you'll need:

function custom_query_vars( $query_vars )
{
$query_vars[] = 'did';
return $query_vars;
}
add_filter( 'query_vars', 'custom_query_vars' );



You will have to remember re-save the permalinks settings.

cheers


raymond comments:

Thanks for the redirect suggestion. I believe this will work but I'm trying to avoid this workaround because there is still have a lot of redirects that Google haven't fully transfer to the new location. (That is a different problem...)

Someone seems to have managed to modify WP Super Cache to super cache query strings urls but I have not given it a try. I think the moded plugin caches all query strings but I prefer to just super cache url with query string "?did=XX".
http://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters#post-1949258

Can you check?


Dbranes comments:

Here is the <em>diff</em> between wp-super-cache (0.9.9.8) and wp-super-cache-getmod

[[LINK href="http://pastebin.com/29ELCjB6"]]http://pastebin.com/29ELCjB6[[/LINK]]


raymond comments:

You think that would work?
I believe that modded version will super cache all query strings url if it worked?


Dbranes comments:

I found these explanations from the mod-author:

<blockquote>My modified version simply throws away any GET variables in the request, it's up to the reader to setup the theme to use ajax to parse any necessary dynamic content from the GET string. This helps to further reduce overhead since in the stock version any url with a query string is never cached.</blockquote>

and

My modded version of the plugin linked above completely ignores query variables. It throws them away and treats the request as if it didn't have them, serving or caching as necessary. I work the ignored query params in my theme by parsing them with javascript for the few i'm expecting. ( like http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html )


Dbranes comments:

ps: I wonder if you have tested W3TC?

It seems to have this setting:

Cache URIs with query string variables

I wonder if it's what you need?


raymond comments:

I used W3TC many years back and some of the features didn't work properly with my dedicated server.
Tried WP Super Cache and everything works quite nicely.

Do you think you can modify the modded version a little bit to only cache urls with query strings did=XX?


raymond comments:

I've applied the changes from the modded WP Super Cache to the current 1.4 and the URL with query strings are still being wp-cached and not super cached.


raymond comments:

Is this task impossible? Or the offered price too low?

2013-11-11

phppoet answers:

which plugin is creating pages with permalink structure http://www.raymond.cc/blog/download/?did=XX ? (want to know for testing )

wp-super cache already does not support http://www.raymond.cc/blog/?p=123 type permalink structure .

regards


raymond comments:

I'm using Download Monitor plugin, 3.3.6.2 legacy version.
http://downloads.wordpress.org/plugin/download-monitor.3.3.6.2-legacy.zip

The latest "rewritten" version no longer uses query string but due to a lot of code modification is done on the installed Download Monitor plugin, I think it'll be more work to upgrade to the latest version and merge all the changes to it.

2013-11-11

Francisco Javier Carazo Gil answers:

Instead of using WP Super Cache in this cases I prefer Varnish directly. Much more efficent and much more powerful.

https://www.varnish-cache.org/


raymond comments:

I'm running LiteSpeed Enterprise which already has caching feature but I prefer something that's easier to manage which is why I opted for WP Super Cache.


Francisco Javier Carazo Gil comments:

At the end, Varnish is so easy as it because you can directly manage it via plugin and there are many VCL in the net to adjust anything (although a typical configuration should be enough).