hunghvu / hungvu.tech

The official repository for hungvu.tech
https://hungvu.tech
3 stars 0 forks source link

Site is not cached in Cloudflare #98

Closed hunghvu closed 9 months ago

hunghvu commented 9 months ago

image

# Response header
cache-control: private, no-cache, no-store, max-age=0, must-revalidate
cf-cache-status: BYPASS

It seems the page bypass Cloudflare cache, resulting in a very low cache hit.

hunghvu commented 9 months ago

Added these rules. We will monitor for a few days to observe the behavior.

image

image

hunghvu commented 9 months ago

These can be useful resources:

hunghvu commented 9 months ago

After further investigation here is the observed behavior.

hunghvu commented 9 months ago

The caching issue is due to the way Next.js sets headers. If Cloudflare ignores the headers, then it can enforce caching. Let's push this issue back to milestone v1.2. For now, a workaround in Cloudflare is sufficient. We will resolve the root cause later on.

Relates to #58, #77, #81.

image image

hunghvu commented 9 months ago

Since overriding the header, the cache ratio is now at a good spot. image

hunghvu commented 9 months ago

The cache has been working well since our fixes during v1.1 development. Two main things were implemented.

It is important that the status code TTL of Edge must be specified, or else the cache rule will not work.

image image

This issue can be closed now.