Header set Cache-Control "max-age=15778463"
</FilesMatch>
+ <FilesMatch "\.(css|js|svg|gif|png|jpg|ico|wasm|tflite)(\?v=.*)?$">
+ Header set Cache-Control "max-age=15778463, immutable"
+ </FilesMatch>
+
# Let browsers cache WOFF files for a week
<FilesMatch "\.woff2?$">
Header set Cache-Control "max-age=604800"
$iconFile = $this->imageManager->setCachedImage('icon-' . $app . '-' . str_replace('/', '_',$image), $icon);
}
$response = new FileDisplayResponse($iconFile, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);
- $response->cacheFor(86400);
+ $response->cacheFor(86400, false, true);
return $response;
}
->with('icon-core-filetypes_folder.svg')
->willReturn($file);
$expected = new FileDisplayResponse($file, Http::STATUS_OK, ['Content-Type' => 'image/svg+xml']);
- $expected->cacheFor(86400);
+ $expected->cacheFor(86400, false, true);
$this->assertEquals($expected, $this->iconController->getThemedIcon('core', 'filetypes/folder.svg'));
}
try {
$f = $this->preview->getPreview($node, $x, $y, !$a, $mode);
- $response = new FileDisplayResponse($f, Http::STATUS_OK, ['Content-Type' => $f->getMimeType()]);
- $response->cacheFor(3600 * 24);
+ $response = new FileDisplayResponse($f, Http::STATUS_OK, [
+ 'Content-Type' => $f->getMimeType(),
+ ]);
+ $response->cacheFor(3600 * 24, false, true);
return $response;
} catch (NotFoundException $e) {
return new DataResponse([], Http::STATUS_NOT_FOUND);
* @return $this
* @since 6.0.0 - return value was added in 7.0.0
*/
- public function cacheFor(int $cacheSeconds, bool $public = false) {
+ public function cacheFor(int $cacheSeconds, bool $public = false, bool $immutable = false) {
if ($cacheSeconds > 0) {
$pragma = $public ? 'public' : 'private';
- $this->addHeader('Cache-Control', $pragma . ', max-age=' . $cacheSeconds . ', must-revalidate');
+ $this->addHeader('Cache-Control', sprintf('%s, max-age=%s, %s', $pragma, $cacheSeconds, ($immutable ? 'immutable' : 'must-revalidate')));
$this->addHeader('Pragma', $pragma);
// Set expires header