• Resolved Maya

    (@tdgu)


    Hi,
    Is there a way to ignore the cached page data ( to not serve it ) if a specific cookie is not set? I presume that has to be done through the .htaccess file.
    So when a user loads the website, the WordPress/plugins php code gets always executed rather than a cached page loaded from the static file, the W3 cache previously loaded. That until the specific cookie exists, then the cached will be served.

    Thanks

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @tdgu

    Thank you for reaching out.
    I just want to confirm that I understood your request.
    What you want is to be able to serve cached pages only if a specific cookie is set and not to serve cached pages at all unless that cookie is set.
    Please let me know if I understood this correctly.

    Thanks!

    Thread Starter Maya

    (@tdgu)

    Hi,
    Yes, this is correct. I need the cached pages to be served Only if a specific cookie exists on the user side (browser).

    Thanks

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @tdgu

    I am not quite sure this is possible as usually, the users want to prevent serving of the cached pages when specific cookie is set.
    In Performance>Cache Groups, you can enable/add a group of of Cookies by specifying names in the Cookies field. Assign a set of Cookies to ensure that a unique cache is created for each Cookie group.
    So adding a specific cookie for some pages, and then excluding that cookie from the cache may be the way to go, and with managing the cookie group allowing the unique cache to be created for the set cookie.
    I need to check and test this more. Thank you for you patience and I’ll get back to you as soon as I have more information.

    Thanks!

    Thread Starter Maya

    (@tdgu)

    Hi,
    What do you think of an additional line within the rewrites:

    RewriteCond %{REQUEST_METHOD} !=POST
    RewriteCond %{ENV:W3TC_QUERY_STRING} =""
    RewriteCond %{HTTP_COOKIE} (serve_if_this_cookie) [NC]
    RewriteCond %{HTTP_COOKIE} !(comment_author|wp-postpass|w3tc_logged_out|wordpress_logged_in|wptouch_switch_toggle) [NC]
    RewriteCond %{HTTP_USER_AGENT} !(W3\ Total\ Cache) [NC]
    RewriteCond "%{DOCUMENT_ROOT} ...../wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SLASH}%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" -f
    RewriteRule .* "....../wp-content/cache/page_enhanced/%{HTTP_HOST}/%{REQUEST_URI}/_index%{ENV:W3TC_SLASH}%{ENV:W3TC_SSL}%{ENV:W3TC_PREVIEW}.html%{ENV:W3TC_ENC}" [L]

    Notice the cookie check RewriteCond %{HTTP_COOKIE} (serve_if_this_cookie’) [NC] There is another similar block where that would go.
    Will that work? If yes, is there a filter which I can use to insert that line?
    Or maybe there is more, of which I’m not aware?

    Thanks

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hey @tdgu

    Sorry for the late reply.
    I’ve checked this and there is no way to do this via the W3 Total Cache settings.

    This being said, your solution may work.? The?.htaccess?file can include a rule above ours to override the cache rewrite behavior.

    Thanks!

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Supress Cache’ is closed to new replies.