Title: [Plugin: WP Super Cache] cache requests with query string $_GET parameters?
Last modified: August 19, 2016

---

# [Plugin: WP Super Cache] cache requests with query string $_GET parameters?

 *  [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/)
 * I’ve searched around without finding much information related to my question.
 * I’m hoping someone can point me in the right direction to allow WP Super Cache
   to cache pages that include $_GET parameters in the request query string. I’m
   currently using the Quick Cache plugin which has an option to cache requests 
   with query string parms, but I prefer the lower load provided by WP Super Cache
   in mod_rewrite mode.
 * In digging through the plugin code I have managed to find a few dozen places 
   I can comment out where !empty($_GET) type checks are made, and in .htaccess 
   had to comment out
    #RewriteCond %{QUERY_STRING} !.*=.* to allow pages with “
   =” to be cached.
 * That seems to do the trick, but i’m caution to move forward with this solution
   since updates to the plugin will revert my changes. Any chance an official update
   would allow an option for this sort of functionality?
 * Thanks for the great plugin, and for any help or expertise anyone can provide!
 * [http://wordpress.org/extend/plugins/wp-super-cache/](http://wordpress.org/extend/plugins/wp-super-cache/)

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/page/2/?output_format=md)

 *  [allieai](https://wordpress.org/support/users/allieai/)
 * (@allieai)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886923)
 * Hi Tmuka, How is your solution working so far, any issues? I am in the same boat.
   Thanks.
 *  [Dinar Qurbanov](https://wordpress.org/support/users/qdinar/)
 * (@qdinar)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886924)
 * `#RewriteCond %{QUERY_STRING} !.*=.*`
    – i think, this will not be enough.
 * wp super cache should save such files.
 * i have made such thing, but you need to be server admin to do so:
    make file,
   executable: my is called aylandirow1.php , with this code:
 *     ```
       #!/usr/bin/php
       <?php
       set_time_limit(0);
       $fdin=fopen("php://stdin","r");
       $fdout=fopen("php://stdout","w");
       set_file_buffer($fdout,0);
       $nini=array('/','?');
       $nige=array('%2F','%39');//3f
       while($i=fgets($fdin)){
       	$o=str_replace($nini,$nige,$i);
       	fputs($fdout,$o);
       }
       ?>
       ```
   
 * then make rewrite rules like this, but modify for wordpress:
 *     ```
       RewriteEngine On
       	RewriteMap aylandirow1 prg:/var/www/saytlar/izlaw/aylandirow1.php
       	RewriteCond %{QUERY_STRING} (.+)
       	RewriteRule /arhif/(....)/(..)/(..)/(.+) /var/www/saytlar/izlaw/arhif/$1/$2/$3/${aylandirow1:$4}\%39%0 [type=text/html]
       	RewriteRule /arhif/(....)/(..)/(..)/(.+) /var/www/saytlar/izlaw/arhif/$1/$2/$3/${aylandirow1:$4} [type=text/html]
       ```
   
 * i have encoded “?” character with “%39” , because i had some problems with handling“?”
   character with rewrite rules. “%39” is “9”‘s code, but it is not used, because“
   9” is not encoded.
    so, wp-super-cache need to be modified to be replacing “?”
   with “%39” or other similar way to work this way. for that ask donncha.
 * this code is used in a very little and simple search engine that i made 🙂 [http://izlaw.tmf.org.ru/](http://izlaw.tmf.org.ru/)
   to serve indexed pages, they are saved by search engine.
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886926)
 * Hi allieai, my attention has been sidetracked from working on/testing this for
   now. It seemed to work, but I didn’t test extensively, so i’m sure there may 
   be edge cases I missed, like search and login or something, etc.
 * qdinar, i commented out “#” that rewrite line above so that supercache WOULD 
   cache urls containing the equals character. My goal was to eliminate the need
   for php with previously cached url requests, including the ones with query strings
   params. Of course, i’m sure there are many ways to solve this problem, hopefully
   yours works satisfactorily for you!
 * I am curious to hear from donncha on potential gotchas I may be missing here.
 *  Plugin Author [Donncha O Caoimh (a11n)](https://wordpress.org/support/users/donncha/)
 * (@donncha)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886932)
 * tmuka – urls with GET parameters aren’t cached as supercache files because the
   characters they use, specifically ? may cause problems on some filesystems. With
   that line commented out, try doing a search on your blog and it won’t work. You’ll
   get the homepage again.
 *  [Dinar Qurbanov](https://wordpress.org/support/users/qdinar/)
 * (@qdinar)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886934)
 * “?” causes problems even before reaching [any] filesystem, when it goes through
   rewrite rules, because rewrite rules cuts request_uri into 2 parts by “?” character,
   and then part after “?” is in rewritecond, part before “?” is in rewriterule.
   for that i have posted my solution how i made rewrite rules for that.
 * > qdinar, i commented out “#” that rewrite line above so that supercache WOULD
   > cache urls containing the equals character.
 * hm have you tested it? i thought super cache php files refuse to save (to cache)
   urls with parameters after “?”, or at least save all variants with different 
   parameters after “?” but same string before “?” as one file, with part after “?”
   cut off.
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [15 years, 3 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886938)
 * donncha & qdinar, thanks for the response, i appreciate the expertise.
 * qdinar, i did modify the plugin so it would cache requests with query string 
   parameters. my tests probably worked since in my case it didn’t matter if i ignored
   the query string arguments, i just needed the pages cached for performance reasons.
 * I’m not testing w3-total-cache which has an option to cache requests with query
   string args.
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886942)
 * I still need to do some more testing, but it seems like my simple mod is working
   with query string param caching, even differentiating between queries such as/?
   s=one and /?s=two
 * it’s by no means extensively tested, but it seems to be working for my configuration
   on dreamhost. Give it a try if you care to, let me know if it works for you…
 * [http://tonymuka.com/wp-super-cache-getmod.tar.gz](http://tonymuka.com/wp-super-cache-getmod.tar.gz)
   
   Of course, all credit for all but a few comments in this code go to donncha. 
   If he prefers me take this down, i’ll be happy to.
 *  [allieai](https://wordpress.org/support/users/allieai/)
 * (@allieai)
 * [15 years, 2 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886949)
 * Hi all, Thanks for the updates and sharing your approaches. What’s provided sounds
   like something more than Super Cache is intended to offer. I will make sure to
   thoroughly test those approaches if I end up needing this feature.
 * Another thing that I have just noticed: even though I do not have anything like
   what’s been suggested here in place: just plain rewrite settings, I see that 
   page (not post) URLs with GET parameters are actually being cached by Super Cache
   because the timestamp exists in the source code: “Dynamic page generated in 0.402
   seconds”… “Cached page generated by WP-Super-Cache on 2011-03-07…” – How did 
   this happen without the additional rewrite rules? Does Super Cache behave differently
   for pages and posts?
 *  [mywebgrocer](https://wordpress.org/support/users/mywebgrocer/)
 * (@mywebgrocer)
 * [15 years ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886982)
 * So tmuka, your mod is an overwrite of the whole plugin? It couldn’t be accomplished
   by making a plugin for WP Super Cache?
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [15 years ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1886983)
 * That’s right, my getmod version would be used instead of the original. I don’t
   think I could write it as a plugin to extend the original plugin.
 * I have come to understand the reason get arguments aren’t cacheable, that’s because
   using mod_rewrite caching means the base filename is requested and loaded right
   from a static file if they exist, wordpress is not invoked at all.
 * 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.
 * Hope this helps!
 *  [savvyharry](https://wordpress.org/support/users/savvyharry/)
 * (@savvyharry)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1887012)
 * > qdinar, i did modify the plugin so it would cache requests with query string
   > parameters. my tests probably worked since in my case it didn’t matter if i
   > ignored the query string arguments, i just needed the pages cached for performance
   > reasons.
 * wow, this sounds exactly like what i need!
 * in my case… i have a few pages that have a traffic coming in and I would like
   to serve a cached page to the visitors **regardless** of what the query string
   is. so for example:
 * the base url would be: [http://www.domain.com/page1](http://www.domain.com/page1)
 * then, the visitors would come in with query strings attached:
    [http://www.domain.com/page1?tracking=ie&tracking2=xyz](http://www.domain.com/page1?tracking=ie&tracking2=xyz)
   [http://www.domain.com/page1?tracking=firefox&tracking2=xyz](http://www.domain.com/page1?tracking=firefox&tracking2=xyz)
   [http://www.domain.com/page1?tracking=safari&tracking2=xyz](http://www.domain.com/page1?tracking=safari&tracking2=xyz)
   [http://www.domain.com/page1?tracking=ie&tracking2=xyz](http://www.domain.com/page1?tracking=ie&tracking2=xyz)
   [http://www.domain.com/page1?tracking=chrome&tracking2=xyz](http://www.domain.com/page1?tracking=chrome&tracking2=xyz)
 * i want to keep the query strings as it is important for me to track information
   about these users, but I want to serve the cached page as long as the base url
   is the same. is this possible?
 * thank you so much for your help in advance!
 *  [savvyharry](https://wordpress.org/support/users/savvyharry/)
 * (@savvyharry)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1887013)
 * i should add… i tried doing this with w3 total cache and it is simply not supported.
   i made a post here and got no response ([http://wordpress.org/support/topic/plugin-w3-total-cache-varying-query-string-variables-wildcard](http://wordpress.org/support/topic/plugin-w3-total-cache-varying-query-string-variables-wildcard))
 * hopefully this is possible with wp super cache!
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1887014)
 * savvyharry,
 * 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](http://jquery-howto.blogspot.com/2009/09/get-url-parameters-values-with-jquery.html))
 * Hope this helps!
 *  [savvyharry](https://wordpress.org/support/users/savvyharry/)
 * (@savvyharry)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1887015)
 * hey tmuka,
 * sounds great man! it would be a great addition to the plugin code… maybe you 
   can talk to Donncha O Caoimh to add it in 🙂
 * > It throws them away and treats the request as if it didn’t have them, serving
   > or caching as necessary.
 * just want to make sure i am understanding your mod version correctly:
 * step 1) someone comes to the site with [http://www.domain.com/page1?tracking=chrome&tracking2=xyz](http://www.domain.com/page1?tracking=chrome&tracking2=xyz)
 * step 2) modded version of plugin throws the query string away and removes them?
 * step 3) page is served as REGARDLESS of query strings parameters
 * my questions:
 * 1) where and when does the parsing with javascript occur?
    2) can the modded 
   version simply ignore the query string and serve the page, WITHOUT removing the
   query string?
 * thank you so much!!!
 *  Thread Starter [tmuka](https://wordpress.org/support/users/tmuka/)
 * (@tmuka)
 * [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/#post-1887016)
 * I didn’t mean to confuse, the url remains intact including the query string. 
   Then in your theme the javascript parses the window.location string which includes
   the original query string variables and does the necessary actions.
 * Hope this helps!

Viewing 15 replies - 1 through 15 (of 16 total)

1 [2](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/page/2/?output_format=md)
[→](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/page/2/?output_format=md)

The topic ‘[Plugin: WP Super Cache] cache requests with query string $_GET parameters?’
is closed to new replies.

 * ![](https://ps.w.org/wp-super-cache/assets/icon-256x256.png?rev=3506220)
 * [WP Super Cache](https://wordpress.org/plugins/wp-super-cache/)
 * [Frequently Asked Questions](https://wordpress.org/plugins/wp-super-cache/#faq)
 * [Support Threads](https://wordpress.org/support/plugin/wp-super-cache/)
 * [Active Topics](https://wordpress.org/support/plugin/wp-super-cache/active/)
 * [Unresolved Topics](https://wordpress.org/support/plugin/wp-super-cache/unresolved/)
 * [Reviews](https://wordpress.org/support/plugin/wp-super-cache/reviews/)

 * 16 replies
 * 6 participants
 * Last reply from: [savvyharry](https://wordpress.org/support/users/savvyharry/)
 * Last activity: [14 years, 6 months ago](https://wordpress.org/support/topic/plugin-wp-super-cache-cache-requests-with-query-string-_get-parameters/page/2/#post-1887021)
 * Status: not resolved