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

For questions and problems with the CMS core. This board is NOT for any 3rd party modules, addons, PHP scripts or anything NOT distributed with the CMS made simple package itself.
Post Reply
JamesT
Forum Members
Forum Members
Posts: 175
Joined: Tue Sep 08, 2015 10:41 am

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

Post 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
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

Post 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.
JamesT
Forum Members
Forum Members
Posts: 175
Joined: Tue Sep 08, 2015 10:41 am

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

Post 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.
User avatar
velden
Dev Team Member
Dev Team Member
Posts: 3483
Joined: Mon Nov 28, 2011 9:29 am
Location: The Netherlands

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

Post 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.
JamesT
Forum Members
Forum Members
Posts: 175
Joined: Tue Sep 08, 2015 10:41 am

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

Post 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!
Post Reply

Return to “CMSMS Core”