Most in-game png's constantly Revalidated

Hi,

I have html5 games that are loaded in iframes (from the same domain though) which are composed of thousands of small png’s. And I simply cannot figure out how to get these to cache consistently. Obviously, this is a massive drain on the server. When I run chrome dev tools, and click on the png’s, most come up as “Revalidated” with no cache date set (I’m guessing that’s why they’re revalidating?).

First I set up a “cache everything” rule for the entire website… didn’t help.

I set up a “cache everything & edge cache: a month” rule for specifically the folder with the game files and put that as #1… didn’t help. (i tried purging the folder too just in case first and refreshing the page etc).

I tried explicitly adding a rule in .htaccess…
<filesMatch “.(png)$”>
Header set Cache-Control “max-age=84600, public”

…and purging .htacess but still the png’s appear to have no expiration date set when I check in dev tools.

For the separate “browser cache TTL” setting I have tried both “1 year” as well as “respect existing headers”

Here’s the header data for one example… I just tried switching “browser cache TTL” back to “1 year” so now I’m seeing cache dates and yet it’s STILL coming up revalidated… What’s going on??

I should add, sometimes a few of the png’s will show up as a HIT and sometimes i see a few MISSes too, but most of them are revalidated… So… it is working a bit sometimes which makes it even more frustrating somehow…

It’s just wild… some of the png’s have an “age”, some have a “cache-control” max-age… but most have nothing… How can png’s that are so similar and all be in the same folder, have such different http headers??? Is there just too many files? Have I reached the maximum of what Cloudflare can cover??

I just skimmed through the Anime and Animals pages and each one had one image with REVALIDATED, but all the rest were HIT.

Age is how long a cached image has been in the cache.

The all have the same cache-control Max Age.

I don’t know why just one resource was REVALIDATED. Maybe your server is sending another header that Cloudflare filters out:

Hi, thanks.

But those images are totally fine… it’s the in-game images when you actually open the game… Each game has thousands of transparent png’s. This is the bulk of website content and so it’s the bulk of what I must have cached… Right now the server is completely overwhelmed with requests and is buckling.

I tried adding and then removing a header in .htaccess and I don’t have any other setting anywhere that I’m aware of. When I run dev tools, most images don’t show up as having any date. But some will have a date but will be revalidated anyway… it makes no sense. It’s just completely all over the place. Why would a png in one folder have a date, and another not have a date, and 80% get revalidated but 10% get cached? It’s completely wild… Does CloudFlare have a limit on the # of items per page that it’s willing to cache or something?

But now that I look, yeah, even just the regular game thumbnails are doing similar things, although most of these are hit, randomly some are revalidated… Like, two png’s, both created in 2011… both gif’s… one is hit and has an “age” and “cache-control” age. The other is revalidated and has no age set… What is happening…

Thanks for the clarification re: age vs max-age.

I just tried something: when i open the png directly, it does give a HIT status. So I think it’s something about the game structure? The iframe maybe? Is it nested too many folders-deep?

REVALIDATED resets the Age timer, so that header won’t show up until you get a HIT.

No, Cloudflare doesn’t have a limit on cached items.

It’s possible the game is sending a cache-control header in the request:

This topic was automatically closed after 31 days. New replies are no longer allowed.