Page 1 of 1

Caching problem, If-modified-since and Last-modified

Posted: Sat Sep 12, 2020 1:28 pm
by JamesT
I've noticed my site is sending the Last-modified header and sending 304 responses when the If-modified-since header is sent with requests. This is not desirable as crawlers are keeping stale data.

Is there any way to disable this behaviour?

Demo on the CMSMS website:

Code: Select all

GET /about/foundation/ HTTP/1.1
Host: www.cmsmadesimple.org
If-modified-since: Mon, 27 Jul 2020 20:54:40 GMT

Code: Select all

HTTP/1.1 304 Not Modified
Date: Sat, 12 Sep 2020 13:23:25 GMT
Server: Apache/2
Expires: Sat, 12 Sep 2020 14:23:29 GMT
Cache-Control: public, max-age=3600
Vary: User-Agent

Re: Caching problem, If-modified-since and Last-modified

Posted: Sat Sep 12, 2020 6:00 pm
by velden
I don't think CMSMS is doing anything with those headers.
It may be in your .htaccess or server configuration.

I may be wrong but I found no proof of this behavior in the code.

Further I'm curious how you did reproduce this behavior.

Re: Caching problem, If-modified-since and Last-modified

Posted: Sat Sep 12, 2020 6:22 pm
by JamesT
In my web server logs I noticed my website was giving "304 Not Modified" responses to Googlebot, hence my investigation.

I tested it on https://www.cmsmadesimple.org/ and it behaves in exactly the same way as my own website, it sends "Last-modified" and respects "If-modified-since" when sent.

So whatever causes my own website to send and respect these headers is also affecting www.cmsmadesimple.org.

To reproduce the behaviour I used openssl to send the "If-modified-since" header via HTTPS to the server as Googlebot does. The request and response are in my original post.

Re: Caching problem, If-modified-since and Last-modified

Posted: Sat Sep 12, 2020 6:56 pm
by velden
Thanks for the details.

You're right the CMSMS website does the same.
A quick test showed me that the 'cachable' checkbox on the 'Options' tab for the content page changes the behavior.

So uncheck the checkbox for pages that shouldn't be cached this way.

Re: Caching problem, If-modified-since and Last-modified

Posted: Sat Sep 12, 2020 7:06 pm
by JamesT
Thanks, unchecking "cachable" does indeed solve the issue.

This default behaviour seems undesirable, especially as the "If-modified-since" date seemed to be compared against the modification date of index.php and not the content itself!