• Resolved Tommy

    (@baptistej)


    Hello,

    The setting “Set cache control header” don’t seems to not work anymore for HTML pages, I tried to set it to “public” or “no-cache” but when I logout I don’t see header added to the page.

    I have Page Cache disabled. It used to work before.

    Thank you.

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

    (@vmarko)

    Hello @baptistej

    Thank you for reaching out and I am happy to assist you with this.
    Can you please make sure you do not have any custom rules for cache control and expires header in your nginx/apache config file?
    Please share the website URL so I can check this.
    Thanks!

    Thread Starter Tommy

    (@baptistej)

    Hello,

    I have created a test website with only W3TC installed, default WordPress htaccess.
    https://wp-wordpress.czfd2l.easypanel.host/

    This test website is using Apache and I’m not able to set the cache control header for HTML.

    Let me know if you can reproduce the issue.

    Thanks.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @baptistej

    Thank you for your feedback.
    Yes, I can see that the Cache-control header and expires header are not set for the HTML. I’ve tested this on a couple of our environments and once I enable the ” Set cache control header” and “Set expires header” in Performance>Browser Cache>HTML&XML section, save all settings and purge the cache, the headers are set for the HTML.
    I can see that those are set for other files like CSS and JS.
    Can you please check if this is enabled in the HTML&XML section?
    Thanks!

    Thread Starter Tommy

    (@baptistej)

    Yes the setting is enabled.

    When you tried it, did Page Cache was disabled? Because it works when you enable page cache.

    But the header should be present even if you don’t use page cache, it was like that in the past.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @baptistej

    Thank you for your reply.

    Yes, I’ve tested this with both Page Caching enabled and also disabled, and in both cases the Cache-control and expires header is set.
    Do you have any other rules that may be impacting this in the upper lever of the folder structure?
    Thanks!

    Thread Starter Tommy

    (@baptistej)

    This is very strange… I have tested on 2 different install and the header never showed up.

    The servers were completely different, one was using NGINX and the other Apache and I don’t think there was any configuration added to the htaccess or nginx config.

    When I enable Page Caching the header show up…

    Did you logout to check if the header is present? because by default WP add it’s own cache control header to logged in users.

    Thread Starter Tommy

    (@baptistej)

    I did more testing today and I noticed the rules added by W3TC are actually working on .html files, I upload html files on my site and the header was present on the files.

    But all pages generated by WordPress or PHP are not showing the header.

    I found a plugin that can force the header:

    https://www.ads-software.com/plugins/cache-control/

    I don’t know why W3TC is not able to add the header anymore, I hope you found a solution.

    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @baptistej

    Thank you for your feedback.
    I’ll try more tests, but I do not see the problem you are referring to as every time the headers are present no matter if the Page cache is enabled or not.
    This does not depend on a Page cache and yes naturally I was checking this logged out on different browsers and private sessions.

    Thanks!

    Thread Starter Tommy

    (@baptistej)

    @vmarko

    I think the NGINX rule for HTML provided in the nginx.conf by W3TC is not compatible with fastcgi.

    By default if you just include the nginx.conf from W3TC the header will not be added to the pages.

    This is how I added the headers back to my pages:

    location ~ \.php$ {
            include snippets/fastcgi-php.conf;
            fastcgi_pass unix:/var/run/php/php8.1-fpm.sock;
            add_header Cache-Control "no-cache, no-store, must-revalidate, max-age=0" always;
        }
    Plugin Contributor Marko Vasiljevic

    (@vmarko)

    Hello @baptistej

    Thank you for your feedback.
    In some cases, the service needs to be restarted to add the rules or for the added rules to be effective.

    Thanks!

    Thread Starter Tommy

    (@baptistej)

    I have fixed my issue by simply enabling page caching, when page cache is enabled the cache control header is working.

    I couldn’t enable Page Cache before because I was using another caching plugin that have a feature than W3TC doesn’t have. But I have removed this plugin now.

    george202

    (@george202)

    Woocommerce – How to make login / logout links cache independent?

    I have a problem with browser caching.

    Once logged in moving to pages visited previously as anonymous user, causes their cached version to be displayed. It means that “Log in” link will appear, despite the fact that user is already logged. Refreshing page will correct menu link, displaying “Log out”, but it can’t be a solution from user point of view.

    I have the caching plugin disabled now. I went through this issue with the hosting provider and asked them to exclude caching of pages like: /my_account/, /cart/, /checkout/ and others, but still the same situation.

    Please advise what can be the solution. How to make login / logout links cache independent?

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Cache control header no longer working’ is closed to new replies.