Plugin Contributor
iSaumya
(@isaumya)
Hi @cositadmin,
Looking at the response header of your website I do not see this plugin being active: https://i.imgur.com/Tg7fWwx.jpeg
So, either you have disabled this plugin or you have some other page caching plugin installed in your website. If you have disabled this plugin, please enable it back so that we can test your site and also if you have any other page caching plugin like WP Rocket or other installed, please disable that.
There are no other cache plugins installed currently, but I decided to check out htaccess file because we had been using WP Rocket previously. I saw there was still code from WP Rocket in the htaccess file, so I’ve removed it. I’m still not seeing the cache being detected but the error has changed now.
Page caching seems not working for both dynamic and static pages.
Error on dynamic page (https://campground.myselkirk.ca): The plugin is not detected on your home page. If you have activated other caching systems, please disable them and retry the test.
Error on static resource (https://campground.myselkirk.ca/wp-content/plugins/wp-cloudflare-page-cache/assets/testcache.html): Unable to find the Cache-Control response header.
I see the WP Cloudflare Super Page Cache entry in the htaccess file, there is one entry from another plugin after that.
# BEGIN AppPresser CORS 1
# The directives (lines) between BEGIN AppPresser CORS 1 and END AppPresser CORS 1 are
# dynamically generated, and should only be modified via WordPress filters.
# Any changes to the directives between these markers will be overwritten.
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP:Authorization} ^(.*)
RewriteRule ^(.*) – [E=HTTP_AUTHORIZATION:%1]
</IfModule>
# END AppPresser CORS 1
This is from a plugin for Apppresser.
Plugin Contributor
iSaumya
(@isaumya)
Hi @cositadmin,
I’m still not seeing any headers that are added by this plugin in the response header. Can you please try removing the htaccess rules except the WordPress default rule and the rules added by this plugin? Now sure why nothing is showing up in the response header.
This is what’s currently in the htaccess file
RewriteOptions inherit
BEGIN WordPress
RewriteEngine On
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
END WordPress
order allow,deny allow from all
deny from 20.106.252.78
deny from 185.221.132.232
deny from 20.109.51.143
deny from 185.136.205.110
deny from 20.38.4.239
deny from 20.83.59.236
deny from 35.236.102.231
deny from 38.111.114.211
php -- BEGIN cPanel-generated handler, do not edit
Set the “ea-php81” package as the default “PHP” programming language.
AddHandler application/x-httpd-ea-php81 .php .php8 .phtml
php -- END cPanel-generated handler, do not edit
deny from 20.169.228.36
BEGIN cPanel-generated php ini directives, do not edit
Manual editing of this file may result in unexpected behavior.
To make changes to this file, use the cPanel MultiPHP INI Editor (Home >> Software >> MultiPHP INI Editor)
For more information, read our documentation (https://go.cpanel.net/EA4ModifyINI)
php_flag display_errors On php_value max_execution_time 60 php_value max_input_time 90 php_value max_input_vars 3000 php_value memory_limit 256M php_value post_max_size 128M php_value session.gc_maxlifetime 1440 php_value session.save_path "/tmp" php_value upload_max_filesize 64M php_flag zlib.output_compression Off
php_flag display_errors On php_value max_execution_time 60 php_value max_input_time 90 php_value max_input_vars 3000 php_value memory_limit 256M php_value post_max_size 128M php_value session.gc_maxlifetime 1440 php_value session.save_path "/tmp" php_value upload_max_filesize 64M php_flag zlib.output_compression Off
END cPanel-generated php ini directives, do not edit
deny from 195.3.221.95
deny from 195.3.221.96
deny from 195.3.221.94
deny from 195.3.221.1
deny from 195.3.221.2/31
deny from 195.3.221.4/30
deny from 195.3.221.8/29
deny from 195.3.221.16/28
deny from 195.3.221.32/27
deny from 195.3.221.64/27
deny from 195.3.221.96/30
deny from 195.3.221.100
deny from 95.214.55.100/30
deny from 95.214.55.104/29
deny from 95.214.55.112/28
deny from 95.214.55.128/26
deny from 95.214.55.192/29
deny from 95.214.55.200
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.
ExpiresActive on ExpiresByType application/xml "access plus 0 seconds" ExpiresByType text/xsl "access plus 0 seconds"
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
RewriteCond %{REQUEST_URI} ^(.)?/wp-content/wp-cloudflare-super-page-cache/www.myselkirk.ca/debug.log(.)$ RewriteRule ^(.*)$ - [F]
Header set Cache-Control "no-cache, no-store, must-revalidate, max-age=0"
END WP Cloudflare Super Page Cache
The only things I can see are WordPress, Cpanel and the cache plugin.
Also as a part of cleanup I went through our database and WP-Config file and removed all entries from WP Rocket. While I have seen other pages that were not updating now are updating. Also I’ve gone and completely uninstalled the Super Page Cache plugin and reinstalled it, this page cache not showing is the only remaining problem.
Plugin Contributor
iSaumya
(@isaumya)
Hi @cositadmin,
Thanks for implementing those fixes. Now I can see the plugin headers are being properly reported in the response header. Also looking at the response header, I can see that despite the plugin setting all headers properly your pages are still not being served from CDN cache.
This is because in the response header I see a set-cookie header for a cookie named WP_SESSION_COOKIE. This is the reason behind your problem. You see, if any plugin or theme that you are using in your WP site is setting any cookies at the PHP level, it creates those cookies using the set-cookie in the response header.
The problem is anytime Cloudflare sees set-cookie is present in the response header, it will never cache that page thinking that the cookie value might be used inside the page to show dynamic content. As a result the page should be served from the origin server.
You can try deactivating this plugin who is adding this cookie and you will see that your cache is working fine. You can also reach out to the plugin developers asking them if there is a way to use the plugin without using the cookies.
To make a site cache friendly, it is very important not to set any cookies at the PHP level. Instead do the checks at the JavaScript level and take advantage of the LocalStorage browser API. Moreover if cookies are must need to be set, it is best to set the cookies at the JavaScript level as it will not conflict with caching.
Screenshot: https://i.imgur.com/GQmu9I4.jpeg