Title: Query string cache for pages and posts
Last modified: February 25, 2020

---

# Query string cache for pages and posts

 *  [eazy0174](https://wordpress.org/support/users/eazy0174/)
 * (@eazy0174)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/)
 * Hello, i have created a page:
 * site.loc/page/
 * this page is cached correctly, but if i use query string for example
 * site.log/page?letter=A then cache won’t work
 * I enabled “query string cache” but it won’t work for pages
    Can you please check?
 * More info:
    Query string on pages are used for custom templates, for example 
   movies list. ?letter=A will show the movie list filtered by letter a, it would
   be cool if cache worked also for this pages.

Viewing 7 replies - 1 through 7 (of 7 total)

 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12476755)
 * can you tell me a sample url please?
 *  Thread Starter [eazy0174](https://wordpress.org/support/users/eazy0174/)
 * (@eazy0174)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12476798)
 * Hello, sorry but i don’t have a live website yet,
    i was developing a solution
   for my client and i noticed this problem.
 * I have something similar to this:
    [https://codepen.io/the_ruther4d/post/custom-query-string-vars-in-wordpress](https://codepen.io/the_ruther4d/post/custom-query-string-vars-in-wordpress)
 * You can replicate the problem creating a page template (page-{ID}.php), then 
   use this function inside:
 *     ```
       if (get_query_var('test')) {
           echo "test ok";
       } else {
           echo "query not set";
       }
       ```
   
 * if you call the page with “site.loc/page?test=value” then it wont be cached.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479027)
 * you can let me know when your site is live.
 *  Thread Starter [eazy0174](https://wordpress.org/support/users/eazy0174/)
 * (@eazy0174)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479234)
 * Sorry but i don’t have any ETA for going online with this website.
    Try to create
   a page on your local wordpress
 * Inside theme directory put a file page-**PAGE_ID**.php where “PAGE_ID” is the
   id of the page you created.
 * Content of page-PAGE_ID.php
 *     ```
       <?php
   
       if (get_query_var('test')): ?>
   
       <html>
   
        <!DOCTYPE html>
           <html>
           <head>
               <meta charset="UTF-8">
               <title></title>
           </head>
   
           <body>
           <?php echo get_query_var('test'); ?>
           </body>
   
           </html>
       <?php else: ?>
       Query not set
       <?php endif;?>
       ```
   
 * functions.php
 *     ```
       function add_custom_query_vars( $qvars ) {
           $qvars[] = 'letter';
           $qvars[] = 'test';
           return $qvars;
       }
       add_filter( 'query_vars', 'add_custom_query_vars' );
       ```
   
 * Now in browser call url:
 * `website.loc/?pagename=contacts&test=3`
 * on the page u can see:
    `WP Fastest Cache file was created in 0.2534019947052
   seconds, on 25-02-20 19:14:39` but every time you refresh, the date changes and
   no cache is created.
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479281)
 * are you admin when you try?
 *  Thread Starter [eazy0174](https://wordpress.org/support/users/eazy0174/)
 * (@eazy0174)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479426)
 * no, you can try it on icognito mode with google chrome
 *  Plugin Author [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * (@emrevona)
 * [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479767)
 * I can test your site when it is live.

Viewing 7 replies - 1 through 7 (of 7 total)

The topic ‘Query string cache for pages and posts’ is closed to new replies.

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

 * 7 replies
 * 2 participants
 * Last reply from: [Emre Vona](https://wordpress.org/support/users/emrevona/)
 * Last activity: [6 years, 3 months ago](https://wordpress.org/support/topic/query-string-cache-for-pages-and-posts/#post-12479767)
 * Status: not resolved