Page MenuHomePhabricator

Bump cache purge value from 30 to 32 days, for webfonts and other large resources
Closed, ResolvedPublic

Description

Author: michael

Description:
Webfonts seem to be delivered with the header Cache-Control: max-age=2592000 (30 days, in seconds).

This means that en.wiktionary could be forcing all 1.6 MB of fonts to be downloaded twice in one billing period, during a 31-day month. This might needlessly accrue a significant cost for someone on a metered internet connection, whether wired or wireless.

The cache should not force a purge until 32 days (2764800 seconds) have passed. It wouldn’t hurt to apply this to any other resources that are set to be purged in 30 days, for all Wikimedia sites.


Version: wmf-deployment
Severity: enhancement

Details

Reference
bz46327

Event Timeline

bzimport raised the priority of this task from to Low.Nov 22 2014, 1:30 AM
bzimport set Reference to bz46327.
bzimport added a subscriber: Unknown Object (MLST).

codecat42 wrote:

Why not have an even longer period? Are such fonts expected to change a lot? They might well be kept the same for years...

michael wrote:

The server sends an etag too, so if the file is changed, then it will be downloaded again anyway.

Does max-age force the cached copy to be deleted?

From my understanding, if a cache sees a max-age directive, after the specified time it would do a request with a If-Modified-Since header, and the server would reply with a HTTP 304 Not Modified (just headers, not entity body) and the client won't need to download the resource again, extending the cache lifetime another "max-age" period.

The idea is interesting, the question is where this code is. :)

Mark: Any idea where this code could be?

Mark: Any idea where this code could be?

Krinkle claimed this task.
Krinkle subscribed.

This was fixed by T102578 and various related tasks. The URLs to these static assets no longer vary by MediaWiki release version, and no longer have a fixed expiry. Instead, they are allowed to be cached by browsers indefinitely, and have a uniquely versioned URL.

I do note however, that in general it is rare for browsers to hold on to cached assets long enough for this to actually matter (unfortunately). The various research I've read from the industry suggests that cached objects are usually discarded within 2 weeks, with a notable minority holding on for upto 4 weeks.