@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Improve cache behaviors for font files and other nonstandard resource types

Summary:
Ref T10843. There are actually two separate notions of cacheability here:

- Is this cacheable by the browser (e.g., should we emit "Expires: long in the future")?
- Is this cacheable locally (e.g., should we stick it in APC, or just read it off disk every time)?

These got a little mixed up by D15775, so we aren't currently emitting proper "Expires" headers on font files and a few other resource types.

Straighten this out so that we "Expires" these unusual resources correctly.

Test Plan: Verified that `.woff` files get a proper "Expires" header now, not just CSS/JS.

Reviewers: chad

Reviewed By: chad

Maniphest Tasks: T10843

Differential Revision: https://secure.phabricator.com/D15807

+4 -4
+4 -4
src/applications/celerity/controller/CelerityResourceController.php
··· 50 50 // is not, refuse to cache this resource. This avoids poisoning caches 51 51 // and CDNs if we're getting a request for a new resource to an old node 52 52 // shortly after a push. 53 - $is_cacheable = ($hash === $expect_hash) && 54 - $this->isCacheableResourceType($type); 53 + $is_cacheable = ($hash === $expect_hash); 54 + $is_locally_cacheable = $this->isLocallyCacheableResourceType($type); 55 55 if (AphrontRequest::getHTTPHeader('If-Modified-Since') && $is_cacheable) { 56 56 // Return a "304 Not Modified". We don't care about the value of this 57 57 // field since we never change what resource is served by a given URI. ··· 60 60 61 61 $cache = null; 62 62 $data = null; 63 - if ($is_cacheable && !$dev_mode) { 63 + if ($is_cacheable && $is_locally_cacheable && !$dev_mode) { 64 64 $cache = PhabricatorCaches::getImmutableCache(); 65 65 66 66 $request_path = $this->getRequest()->getPath(); ··· 168 168 * @param string Resource type. 169 169 * @return bool True to enable caching. 170 170 */ 171 - private function isCacheableResourceType($type) { 171 + private function isLocallyCacheableResourceType($type) { 172 172 $types = array( 173 173 'js' => true, 174 174 'css' => true,