tl;dr; The old /favicon.ico
was 15KB and due to bad caching was downloaded 24M times in the last month totaling ~350GB of server-to-client traffic which can almost all be avoided.
How to save the planet? Well, do something you can do, they say. Ok, what I can do is to reduce the amount of electricity consumed to browse the web. Mozilla MDN Web Docs, which I work on, has a lot of traffic from all over the world. In the last 30 days, we have roughly 70M pageviews across roughly 15M unique users.
A lot of these people come back to MDN more than once per month so good assets and good asset-caching matter.
I found out that somehow we had failed to optimize the /favicon.ico
asset! It was 15,086 bytes when, with Optimage, I was quickly able to turn it down to 1,153 bytes. That's a 13x improvement! Here's what that looks like when zoomed in 4x:
The next challenge was the Cache-Control
. Our CDN is AWS Cloudfront and it respects whatever Cache-Control
headers we set on the assets. Because favicon.ico
doesn't have a unique hash in its name, the Cache-Control
falls back to the default of 24 hours (max-age=86400) which isn't much. Especially for an asset that almost never changes and besides, if we do decide to change the image (but not the name) we'd have to wait a minimum of 24 hours until it's fully rolled out.
MDN Web Docs (formerly MDN) was first launched by Mozilla around 2005, and has grown from humble beginnings to being one of the most popular web development resources on the web today. It now boasts over 13 million page views per month, a strong ecosystem of documentation and data, and a lively community of contributors. A web testing deep dive: The MDN web testing report. For the last couple of years, we've run the MDN Web Developer Needs Assessment (DNA) Report, which aims to highlight the key issues faced by developers building web sites and applications. MDN Web Docs (formerly known as the Mozilla Developer Network or MDN) is a free resource for in-depth documentation on web standards such as HTML5, CSS, JavaScript, and much more. MDN's mission is simple: provide developers with the information they need to easily build projects on the open Web. Data and tools related to MDN Web Docs (formerly Mozilla Developer Network, formerly Mozilla Developer Center.) - MDN Web Docs.
Increasingly, web-enabled devices are capable of determining their orientation; that is, they can report data indicating changes to their orientation with relation to the pull of gravity. In particular, hand-held devices such as mobile phones can use this information to automatically rotate the display to remain upright, presenting a wide-screen view of the web content when the device is.
Another thing I did as part of this was to stop assuming the default URL of /favicon.ico
and instead control it with the <link href='/favicon.323ad90c.ico' type='image/x-icon'>
HTML meta tag. Now I can control the URL of the image that will be downloaded.
Our client-side code is based on create-react-app
and it can't optimize the files in the client/public/
directory.
So I wrote a script that post-processes the files in client/build/
. In particular, it looks through the index.html
template and replaces...
...with...
Plus it makes a copy of the file with this hash in it so that the old URL still resolves. But now can cache it much more aggressively. 1 year in fact.
Combined, we used to have ~350GB worth of data sent from our CDN(s) to people's browsers every month.
Just changing the image itself would turn that number to ~25GB instead.
The new Cache-Control hopefully means that all those returning users can skip the download on a daily basis which will reduce the amount of network usage even more, but it's hard to predict in advance.
Last week, Mozilla announced some general changes in our investments and we would like to outline how they will impact our MDN platform efforts moving forward. It hurts to make these cuts, and it’s important that we be candid on what’s changing and why.
First we want to be clear, MDN is not going away. The core engineering team will continue to run the MDN site and Mozilla will continue to develop the platform.
However, because of Mozilla’s restructuring, we have had to scale back our overall investment in developer outreach, including MDN. Our Co-Founder and CEO Mitchell Baker outlines the reasons why here. As a result, we will be pausing support for DevRel sponsorship, Hacks blog and Tech Speakers. The other areas we have had to scale back on staffing and programs include: Mozilla developer programs, developer events and advocacy, and our MDN tech writing.
We recognize that our tech writing staff drive a great deal of value to MDN users, as do partner contributions to the content. So we are working on a plan to keep the content up to date. We are continuing our planned platform improvements, including a GitHub-based submission system for contributors.
We believe in the value of MDN Web Docs as a premier web developer resource on the internet. We are currently planning how to move MDN forward long term, and will develop this new plan in close collaboration with our industry partners and community members.
Thank you all for your continued care and support for MDN,
— Rina Jensen, Director, Contributor Experience