CF-Cache-Status: EXPIRED despite expire time is 1 month

I have this configured in my Nginx configuration file.
location ~* .(css|js)$ {
add_header Cache-Control “public, max-age=2592000”; expires 30d;
}
location ~* .(jpg|ico|jpeg|png|gif|svg|webp|woff|woff2)$ {
add_header Cache-Control “public, immutable, max-age=31536000”; expires 365d;
}
The expired time is set to 1 month and 1 year, but when I loads the page it shows:
CF-Cache-Status: EXPIRED
Date: Fri, 22 Jul 2022 13:23:05 GMT
Expires: Sun, 21 Aug 2022 13:23:05 GMT
Clearly the resource (css file or png etc) is not expired. Am I missing some thing, or doing it wrong?

First of all do you have Browser Cache TTL set to “Respect Existing Headers”?

Second Cloudflare has their own logic for deciding how to keep things in cache, probably based on a lot of factors such as how often the file is requested. And you can’t force them to keep something cached for longer than they want to. Like there’s probably a 0% chance they’re going to keep an image cached for an entire year. Think of it as you’re giving them permission to cache the files for a certain amount of time but the actual amount of time they’re cached will probably be less.

Your cache-control headers are still useful, though, because browsers will honor them… maybe (again, browsers have their own rules and likely won’t keep a file cached for an entire year)

Thanks for the response. I have updated Browser Cache TTL to “Respect Existing Headers”, but the problem still prevails. Even if a resource is expired, then the on next reload it should show a “hit” but it does not. Some files (JS, png etc) are shown expired forever. More over if you visit other websites which have implemented Cloudflare caching (like coursehero), you won’t see any single “Expired” file. Any comments here?

What’s the domain?

Hi @fawad.saleem :grinning:

CF-Cache-Status has nothing to do with Browser Cache TTL

EXPIRED: The resource was found in Cloudflare’s cache but was expired and served from the origin web server.

Expired: Consider extending Edge Cache TTLs for these resources via a Page Rule or enable revalidation at your origin.

1 Like

I like setting Edge Cache TTL in Page Rules, but it can also be set at the origin:

1 Like

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