Page MenuHomePhabricator

Enable gzip transfer encoding for png and ico files in /static
Closed, ResolvedPublic

Description

Our favicon .ico files have gotten larger recently with a bump in resolution and color/alpha depth. While they look great, they've also expanded from a couple kb to for instance 15kb for Wikipedia:

https://en.wikipedia.org/static/favicon/wikipedia.ico

These .ico files gzip very well, however (they're either uncompressed or simple run-length encoding bitmaps, as I recall) and gzip takes that file back down to 2.5kb nicely.

Having the web server auto-gzip the .ico files might be a nice small bandwidth savings, especially on mobile networks.

Details

Reference
bz61443

Event Timeline

bzimport raised the priority of this task from to Medium.Nov 22 2014, 2:59 AM
bzimport set Reference to bz61443.
bzimport added a subscriber: Unknown Object (MLST).

Change 113687 had a related patch set uploaded by Brion VIBBER:
Work in progress: set .svg and .ico files to be compressed on bits.wikimedia.org

https://gerrit.wikimedia.org/r/113687

Krinkle renamed this task from Apply gzip transfer encoding to ICO files from bits.wikimedia.org (favicon.ico) to Enable gzip transfer encoding for png and ico files in /static.Jul 2 2015, 3:46 AM
Krinkle updated the task description. (Show Details)
Krinkle set Security to None.
Krinkle removed a subscriber: wikibugs-l-list.

TIL that since gzipping compressed formats like PNGs is pointless, we usually have rules only applying it to icos and SVGs. In the case of the wikipedia favicon there is 1-2kb to save here.

I'm not sure what the current relationship between /static/ and bits is, but I saw this tidbit in bits that I think explains it, at least in terms of wrong assumption:

https://github.com/wikimedia/operations-puppet/blob/production/templates/varnish/bits.inc.vcl.erb#L87

The favicon is currently served with this MIME type: image/vnd.microsoft.icon which means that it doesn't mach the regexp. It's quite certainly the wrong codepath for /static/, though, but it explains why https://bits.wikimedia.org/favicon/wikipedia.ico is equally ungzipped.

I can't find any SVGs in /static/, so icos should probably be the focus of the fix.

Change 225852 had a related patch set uploaded (by Gilles):
Fix ICO MIME regexps

https://gerrit.wikimedia.org/r/225852

Works, although the icons that are already stored in varnish remain ungzipped, because they were cached that way. Adding a cache-busting parameter makes the fix visible: https://en.wikipedia.org/static/favicon/wikipedia.ico?2