Cache Exclusion and Static File Headers
-
I recently had an issue where a user was seeing a browser cached version of a page, despite the page being part of the URLs to exclude from caching. The page where the user was seeing cached/old/stale data was /all-classes/ and /events/parisian-cuisine/
Despite those pages being excluded from caching, the site owner (not me), and one of their customers, was still seeing old content. I was seeing it correctly. So that lead me to believe it was a browser caching issue. My exclusion settings were as follows:

I eventually tracked it down to .htaccess where WPO was adding a 28 day max age to all files. So I went through WPO settings again looking for anything that was adding a max age of 28 days. I found the setting in Cache > Static File Headers.

I did not want to set that to zero, as that effectively removes ALL browser caching for JS, CSS, and images, but for the time being I added an htaccess directive below the WP Optimize block to override the 28 day expiration for HTML/PHP files.
# CUSTOM: Disable HTML caching
<IfModule mod_headers.c>
<FilesMatch "\.(html?|php)$">
Header set Cache-Control "no-store, no-cache, must-revalidate, max-age=0"
Header set Pragma "no-cache"
Header set Expires "0"
</FilesMatch>
</IfModule>But the real issue here is that, the expectation when I set a group of URLs to be excluded from caching is that they are not cached (whether server-side or browser).
Furthermore the cache should have been purged every 24 hours per the Cache Settings on the Page Cache tab. So even if the exclude URLs wasn’t working properly, the page HTML/PHP should have been cleared after 24 hours.

Ultimately I came to the conclusion that the Static File Headers setting is completely separate from the caching, despite being a tab in the caching section. But nothing was explained on the settings page this setting would case HTML/PHP, JS, CSS, and images to be potentially cached in a users browser for up to the amount of time specified, and that it would completely replace any other caching behavior specified in other tabs.
I realize this plugin is perhaps not aimed at sites that have some API driven dynamic content on certain pages. And perhaps that’s why I’ve had to add a “hack” to make this work as expected. But I do believe that from an average user’s perspective, setting a URL to be excluded from caching, should reasonably lead one to believe that page will not be cached and that site visitors will never see stale content on that page.
Setting a URL exclude in one place in settings should not mean a URL is still cached for 28 days because of a setting elsewhere in the plugin. Exclude should override EVERYTHING as though it’s completely ignored by the plugin. If I exclude something, I want it excluded. Absolutely.
You must be logged in to reply to this topic.