Hi,
I am new to this community and trying fastly and I want to cache everything as like user do on cloudflare that matching /product/ will cache forever as the data like pricing and everything is fetched from uncached backend but I am unable to do this also I want to ignore origin’s cache controll for this.
Please anyone help me in achiving this.
Hey @sujoydhar2k20, the best practice for working with Fastly for caching is:
-
Set a fallback TTL for all of your content without Cache-Control header instructions from your origin: Controlling caching | Fastly Documentation
-
Then exclude the content that shouldn’t be cached via UI configuration: Temporarily disabling caching | Fastly Documentation
- By default, responses from your origin that contain
Set-Cookie headers, or explicit Cache-Control or Surrogate-Control headers to prevent caching will be respected. The UI instructions above are for fine-grained control beyond your origin’s instructions.
It is also important to understand that Fastly’s caching is a cache, it is not permanent storage. Responses retrieved from your origin may be cached, for up to the maximum time permitted by the origin (via response headers) or VCL controls, but they may only be cached for a very short time if your site has very low traffic in the POP where the requests landed. Responses will be removed from the cache if a busier site in the Fastly platform requires that cache space.
Use of shielding can help with this, as you can concentrate all of the requests for your service to a single POP, thus increasing the request rate and causing it to be more likely for those responses to stay in the cache. There is still no guarantee that they will stay in the cache forever, or even for the time period you specify.