Cache age not consistent in subsquencial requests

Problem:

  • When accessing an endpoint (a specific part of a website) twice in a row, the information about how long it’s been stored in the cache (like a temporary storage for quick access) seems inconsistent.
  • It looks like the cache isn’t behaving as expected, which could lead to potential problems.

Key Points:

  • Age Inconsistency: The “Age” header, which shows how long the content has been in the cache, decreased instead of increasing between requests. This is unexpected.
  • Last-Modified Change: The “Last-Modified” header, which indicates when the content was last updated, also changed between requests. This is unusual if the content itself hasn’t changed.
  • Cache Settings: The cache settings for the endpoint are set to allow caching for up to 14400 seconds (4 hours).
  • Services Involved: The endpoint is hosted on Railway.app, and Cloudflare is acting as a proxy for the DNS (the system that translates website names into computer addresses).

Logs

HTTP/1.1 200 OK
Age: 1281
CF-Cache-Status: HIT
CF-RAY: 8480ee45dbdb7717-LHR
Cache-Control: max-age=14400, cache-type=public
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Fri, 19 Jan 2024 17:52:18 GMT
Last-Modified: Fri, 19 Jan 2024 17:30:57 GMT

and then

HTTP/1.1 200 OK
Age: 1264
CF-Cache-Status: HIT
CF-RAY: 8480ee4dad4edd77-LHR
Cache-Control: max-age=14400, cache-type=public
Connection: keep-alive
Content-Encoding: gzip
Content-Type: text/html; charset=utf-8
Date: Fri, 19 Jan 2024 17:52:20 GMT
Last-Modified: Fri, 19 Jan 2024 17:31:16 GMT

Question: is cache 100% distributed which would explain the differences in the age of cache?

The different Last-Modified headers strongly indicate that you hit different instances of the cache on your requests.

Every Cloudflare location has it’s own cache, and some of the larger locations like London (LHR) even have multiple instances.

So your results are as expected…

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.