• eazy0174

    (@eazy0174)


    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

    (@emrevona)

    can you tell me a sample url please?

    Thread Starter eazy0174

    (@eazy0174)

    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

    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

    (@emrevona)

    you can let me know when your site is live.

    Thread Starter eazy0174

    (@eazy0174)

    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

    (@emrevona)

    are you admin when you try?

    Thread Starter eazy0174

    (@eazy0174)

    no, you can try it on icognito mode with google chrome

    Plugin Author Emre Vona

    (@emrevona)

    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.