Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

WP Super Cache certain Query Strings URL WordPress


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.

I would like to super cache a specific URL type with query string which is: (Replace XX with incremental numbers)


Answers (3)


Dbranes answers:

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

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_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.


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".

Can you check?

Dbranes comments:

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

[[LINK href=""]][[/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>


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 )

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?


phppoet answers:

which plugin is creating pages with permalink structure ? (want to know for testing )

wp-super cache already does not support type permalink structure .


raymond comments:

I'm using Download Monitor plugin, legacy version.

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.


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.

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).