Set an expiry date or max age HTTP header for font resources



Mozilla Developer Network
3 years ago
3 years ago


(Reporter: groovecoder, Unassigned)





(1 attachment)

Severity: normal → minor
Component: Performance → Code Cleanup
Keywords: in-triage
Component: Code Cleanup → Performance
So first of all, this is an issue that not only happens to our styles (base/fonts/opensans.styl) but also happens to files in the Tabzilla CSS:

I'm not sure why we need to use the to be honest, I guess that's to make sure the files are properly cached from one central Mozilla source instead of ten of all the various Mozilla websites. And I guess the low expiry could be there so the file serving works without having to use a cache busting hash in the URL.

On the other hand this could be an issue with the httpd or load balancer setup of not setting long expiry values for font files correctly. I'm not sure.


1. Ask webops to check if the setup is correct and fix it if possible.

2. Host font files on our own CDN ( and stop depending on That would probably also mean to stop serving Tabzilla as well.

Leaving it to Stephanie to make a decision :)
:pmac Do you know what's wrong with the mozorg CDN?
:craigcook Or maybe you can shed some light on this?
Flags: needinfo?(pmac)
Flags: needinfo?(craigcook.bugz)
The short answer is that this is the default cache expiry for static files on bedrock. We could make it longer. We use hashed file names in bedrock itself so that we can set effectively infinite cache timeouts for most files, but sites outside of bedrock that don't have access to the manifest mapping of original file names to hashed file names can't do that.

The best solution for you is to host the files yourself. Tabzilla is about to be replaced by a much more simple and static thing ( so you'll need to host your own fonts at that point anyway since new Tabzilla won't require them.

Another option is to just use our hashed version of the tabzilla CSS, which is very unlikely to change now that we're working on the new thing:

But that does carry some risk. It should stay there as we don't delete these generated files, and the CDN should cache them for 10 years, but I can understand if you're reluctant to use that. It could be a decent interim solution if you need a quick one though.

Hope this helps. We're happy to make whatever changes you need though. If you have a recommendation for a better default cache timeout I'm quite happy to change that as well.
Flags: needinfo?(pmac)
Flags: needinfo?(craigcook.bugz)

Comment 5

3 years ago

"We recommend a minimum cache time of one week and preferably up to one year for static assets, or assets that change infrequently."

Since I assume these font assets don't change much at all, could we set the cache timeout to 1 week?
Flags: needinfo?(pmac)
:groovecoder Could we just start hosting those files on our own once pipeline is merged?

Comment 7

3 years ago
Yeah, I like that best as a long-term, across-the-site fix for proper browser caching. I only filed the bug for these assets because they are the only ones reported by Google Analytics with such a short expiration.

:pmac - how long would it take to make the default cache timeout change on your side? Can you do that while we work on django-pipeline to host the files on our own?
Yup. I'll set the font files to a month by default. Cool? The simple and static tabzilla release is imminent by the way:

There will be an email to the public webdev list when it's fully ready.
Flags: needinfo?(pmac)
Created attachment 8634331 [details] [review]
Link to Github pull-request:

This PR sets cache-control header for all files under the /media/fonts/ URL to 30 days. It also increases the default expiry for all non-immutable files to 6 hours instead of 1 minute.

Comment 10

3 years ago
Commits pushed to master at
Bug 1182126: Increase fonts cache header to one month.

Also increase default cache header expiry to 6 hours from 1 minute.
The majority of files used on bedrock are immutable (include the
file content hash) and will be unaffected by this change.
Merge pull request #3128 from pmclanahan/increase-fonts-cache-expire-1182126

Bug 1182126: Increase fonts cache header to one month.

Comment 11

3 years ago
Thanks :pmac! As of this change, GA speed suggestions no longer mentions these assets. Do you know when this was deployed, so I can check before/after page speed numbers in GA?
Last Resolved: 3 years ago
Flags: needinfo?(pmac)
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.