• Resolved Sean

    (@sean-h)


    When I make changes to any of my sites with this feature on, but especially when my wife publishes a new daily food recipe and a previous visitor (including myself) returns to the site they don’t see the changes or the recipe in the ‘latest recipes feed’ on the homepage.

    I finally solved the problem by simply turning the ‘Leverage Browser Cache’ toggle off and pages/posts still appear to be cached by the browser and subsequent changes are reflected if you revisit the page by a standard link/bookmark.

    Part of my trouble shooting involved completely deleting an entire test website from cPanel; files, database, addon domain, the lot, yet I could continue to surf the site from a previously used browser until I clicked the refresh button or attempted to visit a page that had not previously been visited with that browser.

Viewing 6 replies - 1 through 6 (of 6 total)
  • Thread Starter Sean

    (@sean-h)

    Just a quick follow up.

    I said in my previous post that it appeared my browser was still caching, but GTmetrix said otherwise. So I continued looking, and found then modified this little gem which now replaces the loooong set of leverage browser cache rules normally put in htaccess by the SG plugin:

    # 1 Month for most static assets
    <filesMatch “.(css|jpg|jpeg|png|gif|js|ico)$”>
    Header set Cache-Control “max-age=2592000, public, no-cache”
    </filesMatch>

    Now GTmetrix is happy, and any changes made are now shown by simply surfing to the page, without having to force a refresh. In other words, returning visitors who come back via a bookmark they may have saved will now see my wife’s latest recipe ??

    Happy days are here again ??

    Are you saying you edited htaccess, replacing SG’s code with this snippet? I wonder if any changes at all in the SG plugin will update htaccess, again adding their cache rule, and possibly removing your replacement.

    When I edit CSS for a client site, I need those changes to work instantly. I’m ok with flushing a wp/server cache, but I’m very concerned about a browser cache that I can’t flush at will.

    Thread Starter Sean

    (@sean-h)

    htaccess is my favourite happy place ?? But if you know what the htaccess file is, you will also know it is 100% syntax sensitive. Check your site immediately after making any changes to it.

    I first turned the ‘Leverage Browser Cache’ toggle off in the Optimizer plugin. This automatically removes the file from htaccess, just as long as you have not modified the # tags, because that’s how the plugin knows which code to remove. # tags are otherwise ignored by the server, they are merely for reference, for plugins and us humans.

    So as long as that toggle remains off, it will not put that cache code back, but even if it does, it will not remove any other code. The problem you need to be sure of is that no plugin or any other rules are trying to do the same thing. You should only cache stuff once.

    Try that snippet, right at the top of the htaccess. Make some changes, test. It seems to work quite well for me. Just note that any browser that has visited your site before you added this rule will need a force refresh.

    Incidentally, I have all other features of the SG Optimizer plugin on, except Leverage Browser Cache, unless I have completely missed the boat on this one and it should otherwise work.

    Yes, I’ve got nothing much else to do right except to write gibberish.

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Awesome ?? That would become obsolete though once we update the regular .htaccess rule excluding HTML. Not sure why you’re disabling images from the cache though? If they are modified, browsers will fetch them anew even if the default cache is set to an year or something like that.

    Thread Starter Sean

    (@sean-h)

    To be honest, I’m not really sure what I’m doing ?? I’m a proper wannabe/amateur web designer, got nothing better to do right now ?? All I can say is that things seem to be working much better. I did so much testing I ended up maxing out the CPU on my GoGeek, probably more out of boredom. Oops.

    Thread Starter Sean

    (@sean-h)

    There has been an interesting development after some more experiments: (yes, I have some time on my hands right now, but I don’t want to max out my account CPU, again)

    I turned the SG Optimizer Leverage Browser Cache back on, but I then put just this line of code:

    Header set Cache-Control “no-cache”

    above the code now added to the htaccess for browser caching, right at the top of the htaccess file. My research (aka Gooogling) reveals that that line actually allows caching and a browser can serve its own cache but only after it has first verified with the host server that there have been no changes. So far, so good. Stuff appears to load even faster, except when I navigate to a page that has been changed, because the browser is now fetching the changes and not serving its stale cache. No force refresh required.

    However, if I remove that single line of code but leave the long browser cache code, any changes are not reflected unless I force a browser refresh, something none of us can ask our 100’s if not 1000’s of daily return visitors to do.

    Anyone? Bueller? Anyone?

    • This reply was modified 4 years, 7 months ago by Sean. Reason: Block quote added correctly
Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Leverage Browser Caching’ is closed to new replies.