Check with HEAD request if page has changes

I have a script which loads a kirby content representation (foo.xml). I have caching enabled in the kirby config.php file. Now I want to know, when or if this foo.xml has changed. But the expires header in the response to my HEAD request never changes, it is always “Expires: Thu, 19 Nov 1981 08:52:00 GMT”. What other field can I look at? Is this even a valid approach?
When would the page return a 304 Not Modified?

I’ve never seen Kirby reply with 304 Not Modified. I think it always replies with a 200 status (plus some 404 for the error page, and 301 when using the redirection helpers). It’s fairly rare for a CMS to handle 304s.

Also I’m pretty sure the Expires header you’re seeing was not set by Kirby, but more likely by your web server.

If your script is doing something like pull XML from a Kirby website, and if the content changed feed it to an update process of some kind, I think you have 3 options:

  1. Don’t check if the content is different, just run the update anyway.
  2. Check the XML on the script’s side: keep a copy, compare with previous copy.
  3. Implement correct 304/Expires/other signals you need on the Kirby side for this content, probably in a controller or route (not sure how compatible this is with the Content Representation method… you may have to skip it). Maybe look into Kirby Toolkit’s Cache classes (https://getkirby.com/docs/toolkit/api).