mirror of
https://we.phorge.it/source/phorge.git
synced 2024-12-30 01:10:58 +01:00
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
This commit is contained in:
parent
63bbe6b129
commit
fbc4967154
1 changed files with 4 additions and 4 deletions
|
@ -50,8 +50,8 @@ abstract class CelerityResourceController extends PhabricatorController {
|
|||
// is not, refuse to cache this resource. This avoids poisoning caches
|
||||
// and CDNs if we're getting a request for a new resource to an old node
|
||||
// shortly after a push.
|
||||
$is_cacheable = ($hash === $expect_hash) &&
|
||||
$this->isCacheableResourceType($type);
|
||||
$is_cacheable = ($hash === $expect_hash);
|
||||
$is_locally_cacheable = $this->isLocallyCacheableResourceType($type);
|
||||
if (AphrontRequest::getHTTPHeader('If-Modified-Since') && $is_cacheable) {
|
||||
// Return a "304 Not Modified". We don't care about the value of this
|
||||
// field since we never change what resource is served by a given URI.
|
||||
|
@ -60,7 +60,7 @@ abstract class CelerityResourceController extends PhabricatorController {
|
|||
|
||||
$cache = null;
|
||||
$data = null;
|
||||
if ($is_cacheable && !$dev_mode) {
|
||||
if ($is_cacheable && $is_locally_cacheable && !$dev_mode) {
|
||||
$cache = PhabricatorCaches::getImmutableCache();
|
||||
|
||||
$request_path = $this->getRequest()->getPath();
|
||||
|
@ -168,7 +168,7 @@ abstract class CelerityResourceController extends PhabricatorController {
|
|||
* @param string Resource type.
|
||||
* @return bool True to enable caching.
|
||||
*/
|
||||
private function isCacheableResourceType($type) {
|
||||
private function isLocallyCacheableResourceType($type) {
|
||||
$types = array(
|
||||
'js' => true,
|
||||
'css' => true,
|
||||
|
|
Loading…
Reference in a new issue