• Resolved axmann

    (@axmann)


    Hi there,

    since the other topics on this issue haven’t helped me out yet I would like to start a further one.

    My problem is pretty much the same as this (logged in users are served with cache). Unfortunetly I don’t know how to deal exactly with the given solution in the linked topic.

    My htaccess looks like this:

    # START GZIP
    <ifModule mod_gzip.c>
    mod_gzip_on Yes
    mod_gzip_dechunk Yes
    mod_gzip_item_include file .(html?|txt|css|js|php|pl)$
    mod_gzip_item_include handler ^cgi-script$
    mod_gzip_item_include mime ^text/.*
    mod_gzip_item_include mime ^application/x-javascript.*
    mod_gzip_item_exclude mime ^image/.*
    mod_gzip_item_exclude rspheader ^Content-Encoding:.*gzip.*
    </ifModule>
    
    <IfModule mod_deflate.c>
    AddOutputFilterByType DEFLATE text/plain
    AddOutputFilterByType DEFLATE text/html
    AddOutputFilterByType DEFLATE text/xml
    AddOutputFilterByType DEFLATE text/css
    AddOutputFilterByType DEFLATE application/xml
    AddOutputFilterByType DEFLATE application/xhtml+xml
    AddOutputFilterByType DEFLATE application/rss+xml
    AddOutputFilterByType DEFLATE application/javascript
    AddOutputFilterByType DEFLATE application/x-javascript
    </IfModule>
    # END GZIP
    
    # START Browser Cache
    <IfModule mod_headers.c>
    <filesMatch ".(jpg|jpeg|png|gif|ico)$">
    Header set Cache-Control "max-age=31536000, public"
    </filesMatch>
    <filesMatch ".(css|js)$">
    Header set Cache-Control "max-age=2628000, public"
    </filesMatch>
    Header set Cache-Control "max-age=3600, public"
    </IfModule>
    # END Browser Cache
    
    # BEGIN WordPress
    <IfModule mod_rewrite.c>
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ - [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    </IfModule>
    # END WordPress

    If you need any further settings please let me know.

Viewing 9 replies - 1 through 9 (of 9 total)
  • Anonymous User 16850768

    (@anonymized-16850768)

    Can you please provide the page response headers when a user is logged in? The page response headers can be found in your browser’s developer tools Network panel.

    Thread Starter axmann

    (@axmann)

    Hi Corey,

    thanks for your quick answer.

    I hope this is what you need:

    Cache-Control: max-age=3600, public
    Content-Encoding: gzip
    Content-Type: text/html; charset=UTF-8
    Date: Wed, 10 Jul 2019 07:29:22 GMT
    Last-Modified: Wed, 10 Jul 2019 07:21:21 GMT
    Server: Apache

    If not please give me a hint where to find the exact data you need.

    Anonymous User 16850768

    (@anonymized-16850768)

    Thank you, that’s the correct information. I don’t see the x-cache-handler: wp response header, which indicates the page isn’t being delivered from the Cache Enabler cache.

    To confirm this, after a couple hard page refreshes do your pages for logged in users contain the Cache Enabler HTML comment, for example:

    <!-- Cache Enabler by KeyCDN @ 10.07.2019 01:00:00 (html) -->

    If no, this indicates the page is simply being stored in the browser cache, which is being defined by Header set Cache-Control "max-age=3600, public" in your .htaccess file.

    Thread Starter axmann

    (@axmann)

    Not quite sure if I got you right, Corey.

    I’ve checked the code for the HTML comment being logged in and out butit wasn’t there at all. So I figured there must be some kind of conflict with the browser cache like you said. Because of this I removed the corresponding code from my .htaccess file. After this + some hard page refreshes + deleting browser history etc. there’s this situation now:

    Not logged in = HTML comment in the code = page delivered by Cache Enabler (hope I’m concluding this right)

    Logged in = page seems to be rendered without using any cached files

    So it’s actually working right now but honestly I don’t have a clue what x-cache-handler: wp is about (unfortunetly I don’t know how to understand this explanation). It’s still not displayed. Is there anything I could have missed to have a correct setup?

    If you need more information, just let me know.

    Hello

    Add in your htaccess the cache control to private must-revalidate.

    Example:

    <filesMatch "\\.(html|htm|php)$">
        Header set Cache-Control "max-age=86400, private, must-revalidate"
      </filesMatch>
    Anonymous User 16850768

    (@anonymized-16850768)

    Either the x-cache-handler: wp or x-cache-handler: php response header is shown in the page response headers when the page was delivered from the Cache Enabler cache. The Cache Enabler HTML comment is shown when the page was delivered from the Cache Enabler cache.

    Those are the two ways to verify whether or not the page was actually delivered from the Cache Enabler cache. From what you’ve described it sounds like it’s working correctly. You can customize the Cache-Control HTTP header to fit your exact needs.

    Thread Starter axmann

    (@axmann)

    @redcastor Thank you! Tweaked htaccess with that and it’s still working
    @coreyk Thank you as well for the explanation!

    If I see this right the actual reason for the problem was the browser cache and how it was configurated.

    Because of this: Would you recommend to skip browser caching when a caching plugin like Cache Enabler is running (because both is just not necessary)? Or do they complete each other (= better performance)?

    Anonymous User 16850768

    (@anonymized-16850768)

    You’re welcome! The exact configuration will depend on your website and requirements. Leveraging browser caching can be very beneficial to the performance of your website if the user doesn’t need to revalidate the resource on each request.

    If interested, I’d recommend learning more about the Cache-Control HTTP header to know how to configure it for all of your resources.

    Thread Starter axmann

    (@axmann)

    I don’t know why but caching is almost rocket sience for me. So thank you again for your support! I will try to work myself deeper into the matter.

    I’ll might ask you for help again but for now I mark this topic as resolved.

    PS. Regardless of the issue in this topic Cache Enabler has improved the performance of my site significantly compared to other caching plugins from the very first day I’ve installed it. I encourage you to carry on developing it.

    Best regards

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Prevent caching for logged in users’ is closed to new replies.