cachingvarnishfastly

Fastly purges pages for no reason


I have a site that uses Fastly as an FPC, I've blocked all "purge" requests from code in order to keep pages cached as long as I need. "Expire" header has +1 day interval. To test that i've set up a cronjob to open a specific page every minute. It was running for 1 day and all requests returned cached results, but when i set a similar cronjob with an interval of 30min - requests became not cacheable. Is there a setting/mechanism to flush/invalidate cached content if it is not requested for some time? Or what can be a reason for such behavior?


Solution

  • There is a possibility that the cached content is being evicted.

    I would recommend reading through the Fastly Developer Hub page "Cache freshness and TTLs", which states:

    IMPORTANT: We won't necessarily store objects for the full TTL requested, and may evict less popular objects earlier, especially if they are large. We also do not automatically evict objects when they reach their TTL. They simply become stale.

    Additionally, Fastly's "Serving stale content" guide states:

    Fastly has an LRU list, so objects are not necessarily guaranteed to stay in cache for the entirety of their TTL (time to live). But eviction is dependent on many factors, including the object's request frequency, its TTL, the POP from which it's being served. For instance, objects with a TTL of 3700s or longer get written to disk, whereas objects with shorter TTLs end up in transient, in-memory-only storage. We recommend setting your TTL to more than 3700s when possible.

    It would also be worth having a quick read through Fastly's "Caching configuration best practices" guide, in case there's anything mentioned there that you have not yet configured.

    Failing that you should also reach out to support@fastly.com as they're a friendly team who will be able to assist you.