Plugin Contributor
iSaumya
(@isaumya)
For using browser cache you recommend adding some rules to the nginx config, but cloudways refuses to add them and suggested to ask for the htaccess rules that are not same. can you provide them?
– I don’t understand. Most cloudways servers are running Nginx. So, .htaccess
rules will not work on NGINX. I’m so confused. But anyways, here are the htaccess rules for static files browser cache:
# BEGIN WP Cloudflare Super Page Cache
# The directives (lines) between "BEGIN WP Cloudflare Super Page Cache" and "END WP Cloudflare Super Page Cache" are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_expires.c>
ExpiresActive on
ExpiresByType application/xml "access plus 0 seconds"
ExpiresByType text/xsl "access plus 0 seconds"
</IfModule>
<FilesMatch "\.(xml|xsl)$">
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
</IfModule>
</FilesMatch>
<FilesMatch "robots\.txt">
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
</IfModule>
</FilesMatch>
<FilesMatch "\.(css|js|pdf)$">
<IfModule mod_headers.c>
Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"
</IfModule>
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$">
<IfModule mod_headers.c>
Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"
</IfModule>
</FilesMatch>
<IfModule mod_rewrite.c>
RewriteCond %{REQUEST_URI} ^(.*)?/wp-content/wp-cloudflare-super-page-cache/www.nechakooptometry.ca/debug.log(.*)$
RewriteRule ^(.*)$ - [F]
</IfModule>
<FilesMatch "wp-cron.php">
<IfModule mod_headers.c>
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
</IfModule>
</FilesMatch>
# END WP Cloudflare Super Page Cache
on admin pages, some actions are not performed like deleting some export setting from export plugin. When click delete y load the page exactly the same as before. I guess some caching is happening in backend! im using worker mode. can you guide me to solve it ?
– Can you share a screen recording oof the issue?
thanks..contacted back cloudways and replied this:
I configured Apache to handle the static files and then added the required htaccess directives so they will be effective now.
What do you think in your end? thanks
Plugin Contributor
iSaumya
(@isaumya)
Yah that makes sense. Check the response headers if the cache-control
is showing properly. If it is then all ok.
status: 200
Cache-Control: s-maxage=31536000, max-age=60
Date: Wed, 19 Oct 2022 15:45:40 GMT
Vary: Accept-Encoding
x-wp-cf-super-cache-worker-status: hit
nel: {“success_fraction”:0,”report_to”:”cf-nel”,”max_age”:604800}
x-wp-cf-super-cache-cookies-bypass: swfpc-feature-not-enabled
Server: cloudflare
cf-cache-status: HIT
x-wp-cf-super-cache-cache-control: s-maxage=31536000, max-age=60
x-wp-cf-super-cache: cache
x-wp-cf-super-cache-active: 1
I’m also a Cloudways customer and found this thread. Cloudways uses Nginx as a reverse proxy so .htaccess is still valid/required.
I can see that the plugin automatically adds most of the directives listed above to the htacceess file, but not these:
<FilesMatch "\.(css|js|pdf)$">
<IfModule mod_headers.c>
Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=604800"
</IfModule>
</FilesMatch>
<FilesMatch "\.(jpg|jpeg|png|gif|ico|eot|swf|svg|webp|avif|ttf|otf|woff|woff2|ogg|mp4|mpeg|avi|mkv|webm|mp3)$">
<IfModule mod_headers.c>
Header set Cache-Control "public, must-revalidate, proxy-revalidate, immutable, max-age=31536000, stale-while-revalidate=86400, stale-if-error=604800"
</IfModule>
</FilesMatch>
Should I add this to the Super Page Cache directives manually, or are these not needed anymore?
Plugin Contributor
iSaumya
(@isaumya)
Hi @eimpacteric,
Have you enabled the option? Screenshot: https://i.imgur.com/cd7iiPK.jpeg
Cause when the option is enabled, generally the plugin added the data to htaccess if it is writable and plugin can understand the system uses htaccess.
I turned the option off and back on and now it added the code π
Plugin Contributor
iSaumya
(@isaumya)
Glad to hear that @eimpacteric π