Caching static assets with cache policy


I keep getting the message “Serve static assets with an efficient cache policy” on pagespeed tools.

I’m using Hexo static page generator, CloudFlare DNS and Netlify.
In the directory /public I made the file “netlify.toml” with this contents:

for = “/*” # This defines which paths this specific [[headers]] block will cover.
Cache-Control = “public, max-age=604800”

But that seems to have no effect on caching. How can I solve this?


Hi @dev, If you feel comfortable sharing publicly, can you link us to the site that you’re having trouble with? Also note that we manage caching for you automatically. If you’re interested in learning more about this then check out the following blog post:


@futuregerald should we rely on Netlify to cache ALL assets with this method? Are there instances, such as fonts or images (both typically having a long life) that it would be optimal to use a traditional, long max-age, strategy?


If you put a longer cache then browsers won’t have to make a request to see if there’s an updated version of the file, so you can definitely do that. It certainly won’t hurt performance, but the gains would likely be minimal for a high trafficked site. Especially if you end up in a situation where you want to update a file without changing its name.

If your site receives a low amount of traffic then it’s more likely that you’ll have a low cache-hit rate, which means having a higher cache on assets that don’t change may help repeat visitors. As noted above, the gains would be minimal but they may be there.


Thanks, @futuregerald.

the gains would be minimal but they may be there

Ha, well perhaps you’ve never met a webperf fanatic before :slight_smile:

1 Like