resourceloader: Set a TTL for minification cache entries
authorTimo Tijhof <krinklemail@gmail.com>
Tue, 7 Jul 2015 16:40:00 +0000 (17:40 +0100)
committerOri.livneh <ori@wikimedia.org>
Tue, 7 Jul 2015 17:15:37 +0000 (17:15 +0000)
Follows-up 458e7cabbbafd. HHVM's APC cache doesn't have any
limitation or eviction logic. Thus entries without a TTL will
linger indefinitely.

At time of writing over 99% of APC entries were from "resourceloader:filter"
because there are far more unpopular resources than popular ones.

A fixed TTL is suboptimal as it will also cause popular resources
(e.g. startup module, or jquery) to be re-minified every day.

Beware this isn't one single minification. It's one minification,
for every JS/CSS resource, on every app server, for many different
lang/skin/config variations.

Bug: T104769
Change-Id: Ib62c320da0eeede68aad3f2294006ec7dcf1df55

includes/resourceloader/ResourceLoader.php

index 5d0ed3c..e6cb5eb 100644 (file)
@@ -224,7 +224,8 @@ class ResourceLoader implements LoggerAwareInterface {
                                if ( $options['cacheReport'] ) {
                                        $result .= "\n/* cache key: $key */";
                                }
-                               $cache->set( $key, $result );
+                               // Set a TTL since HHVM's APC doesn't have any limitation or eviction logic.
+                               $cache->set( $key, $result, 24 * 3600 );
                        } catch ( Exception $e ) {
                                MWExceptionHandler::logException( $e );
                                $this->logger->warning( 'Minification failed: {exception}', array(