Support » Plugin: WP Super Cache » How to stop header from being cached?

  • How to i prevent header from being cached? I am login in to the sites but the “login text” should show the user gravatar and nickname.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 17 total)
  • Saša

    (@stodorovic)

    It seems that you’ve unchecked option Don’t cache pages for known users. (WPSC settings/Advanced). You can’t exclude only “header” because WPSC created fully static HTML page. It’ll work if you deactivate caching for all logged users (which is usual setting).

    Also, it seems that you website is behind Cloudflare and it’s possible that isn’t WordPress issue. You should “bypass cache” for logged users (cloudflare settings) and you can see more details on https://support.cloudflare.com/hc/en-us/articles/236166048-Caching-Static-HTML-with-WordPress-WooCommerce.

    I have that option ticked (“Don’t cache pages for known users”)
    Indeed when i disable cloudflare the issue does not occur for logged in users

    However the Cloudflare setting “bypass cache on cookie” is not available on their free plan. What is the plan B? Do you recommend to disable cloudflare performance?

    • This reply was modified 7 months, 1 week ago by  csandreas1.
    • This reply was modified 7 months, 1 week ago by  csandreas1.
    • This reply was modified 7 months, 1 week ago by  csandreas1.
    • This reply was modified 7 months, 1 week ago by  csandreas1.

    The main issue here, when you visit a cache page you can’t login using the Tonda theme login widget at the top (as shown in the screenshot)

    Saša

    (@stodorovic)

    I think that simple solution is removing Cloudlflare. You could use free CDNJS for JS/CSS files (to improve loading time) and CDN only for images (I don’t know does it exist for free plan). Also, preload option (it regenerates entire cache at each nnn minutes) in WPSC could help for anonymous visitors.

    Related to login popup, it seems that Tonda theme uses JS/AJAX request. It should work, but it’s possible that CF stores/serves “wrong pages” because it doesn’t check WP cookies.

    You should test with/without CF and then compare performance improvements. Also, you will see is it fixing this issue.

    I do not know if it’s Cloudflare problem, I tried to pause it and sometimes it works sometimes not. I have used chrome, edge and firefox. On firefox sometimes there is problem on the cached pages.

    Even with Cloudflare enabled sometimes the login works. When paused sometimes does not work.

    I am confused can you help me diagnose this issue ?

    i think preloading broke my site 🙂 I see blank pages

    • This reply was modified 7 months, 1 week ago by  csandreas1.
    • This reply was modified 7 months, 1 week ago by  csandreas1.
    Saša

    (@stodorovic)

    I see double “Cache-Control” in HTTP headers:

    Cache-Control: max-age=3, must-revalidate
    Cache-Control: max-age=172800
    

    First (max-age=3) is sent by WPSC, second it seems as custom server rule (172800 seconds=2 days). I think that isn’t CF issue (by quick checking). It could be issue because browser keeps old file and it doesn’t try to retrieve new page from the website.

    I’m not sure that pausing is enough. Anyway, you should remove double Cache-Control from HTTP header. Also, you should enable ETag if it’s possible.

    Related to blank pages, please enable debugging in WPSC (WPSC Settings/Debug) and check PHP error log (enable this log if it isn’t enabled) and apache log. More details: https://www.a2hosting.com/kb/cpanel/cpanel-logging-features/error-log

    i am also using Clearfy plugin but i do not think it’s the issue i tried to disable it as well.

    • This reply was modified 7 months, 1 week ago by  csandreas1.

    How can i enable ETag? Can i just add expire headers?

    Saša

    (@stodorovic)

    Related to expire headers – it’s an issue because second ‘Cache-control’ increases ‘Expires’ to current time + 2 days. So, you should check .htaccess and remove rule for Cache-Control: max-age=172800.

    Related to ETag – you need to remove Header unset ETag from .htaccess (if it exists) and add FileETag MTime Size instead of FileETag None (maybe it doesn’t exist).

    Did you add custom rules in .htaccess related to leverage browser caching or something like this?

    Here is my complete htaccess file

    FileETag MTime Size
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteCond %{REQUEST_URI} !^/[0-9]+\..+\.cpaneldcv$
    RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/[0-9a-zA-Z_-]+$
    RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$
    RewriteRule . /index.php [L]
    </IfModule>
    
    # END WordPress
    
    <IfModule mod_expires.c>
      ExpiresActive On
    
      # Images
      ExpiresByType image/jpeg "access plus 1 year"
      ExpiresByType image/gif "access plus 1 year"
      ExpiresByType image/png "access plus 1 year"
      ExpiresByType image/webp "access plus 1 year"
      ExpiresByType image/svg+xml "access plus 1 year"
      ExpiresByType image/x-icon "access plus 1 year"
    
      # Video
      ExpiresByType video/mp4 "access plus 1 year"
      ExpiresByType video/mpeg "access plus 1 year"
    
      # CSS, JavaScript
      ExpiresByType text/css "access plus 1 month"
      ExpiresByType text/javascript "access plus 1 month"
      ExpiresByType application/javascript "access plus 1 month"
    
      # Others
      ExpiresByType application/pdf "access plus 1 month"
      ExpiresByType application/x-shockwave-flash "access plus 1 month"
    </IfModule>
    
    <IfModule mod_deflate.c>
      # Compress HTML, CSS, JavaScript, Text, XML and fonts
      AddOutputFilterByType DEFLATE application/javascript
      AddOutputFilterByType DEFLATE application/rss+xml
      AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
      AddOutputFilterByType DEFLATE application/x-font
      AddOutputFilterByType DEFLATE application/x-font-opentype
      AddOutputFilterByType DEFLATE application/x-font-otf
      AddOutputFilterByType DEFLATE application/x-font-truetype
      AddOutputFilterByType DEFLATE application/x-font-ttf
      AddOutputFilterByType DEFLATE application/x-javascript
      AddOutputFilterByType DEFLATE application/xhtml+xml
      AddOutputFilterByType DEFLATE application/xml
      AddOutputFilterByType DEFLATE font/opentype
      AddOutputFilterByType DEFLATE font/otf
      AddOutputFilterByType DEFLATE font/ttf
      AddOutputFilterByType DEFLATE image/svg+xml
      AddOutputFilterByType DEFLATE image/x-icon
      AddOutputFilterByType DEFLATE text/css
      AddOutputFilterByType DEFLATE text/html
      AddOutputFilterByType DEFLATE text/javascript
      AddOutputFilterByType DEFLATE text/plain
      AddOutputFilterByType DEFLATE text/xml
    
      # Remove browser bugs (only needed for really old browsers)
      BrowserMatch ^Mozilla/4 gzip-only-text/html
      BrowserMatch ^Mozilla/4\.0[678] no-gzip
      BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
      Header append Vary User-Agent
    </IfModule>
    
    csandreas1

    (@csandreas1)

    We haven’t figured out the issue yet and i am about to uninstall this plugin :/
    An other issue “preloading” does not preload all pages unless i do it manually… i have checked folder and there are pages missing. (my website has only 100 pages)

    • This reply was modified 7 months ago by  csandreas1.
    • This reply was modified 7 months ago by  csandreas1.
    • This reply was modified 7 months ago by  csandreas1.
    Saša

    (@stodorovic)

    I don’t see more double HTTP header, so it seems that you fixed it. I think that you don’t need extra rules for “certificate validation” in WordPress section of .htaccess (removing could little decrease time for processing of request and it should work without it).

    Because your website is behind Cloudflare then you could try without any WP caching plugin. It’ll be helpful to enable OPCache in PHP configuration (sometime it’s available for shared hosting, but you could ask your hosting for more details). Loading time of pages is longer than usual for similar websites (and PHP 7.2).

    Regarding to preload (and other task in backend), it’s helpful to run wp-cron.php from real cron service (I recommend at each 5 or 10 minutes). More details – How to configure a cron job for WordPress.

    csandreas1

    (@csandreas1)

    If you open the console you will notice that the JS/AJAX request is not sent on cached pages. ON INCOGNITO IT WORKS THOUGH, have we splitted the issue enough or not yet?

    csandreas1

    (@csandreas1)

    Clearfy was causing issue with preloading i uninstalled that. Though i did not figure out the issue with the login yet

Viewing 15 replies - 1 through 15 (of 17 total)
  • The topic ‘How to stop header from being cached?’ is closed to new replies.