mirror of
https://github.com/getformwork/formwork.git
synced 2025-01-17 21:49:04 +01:00
Add cache headers to assets
This commit is contained in:
parent
6f43d30b84
commit
fd60bed3a7
@ -14,7 +14,7 @@ class AssetController extends AbstractController
|
||||
$path = FileSystem::joinPaths($this->config->get('system.images.processPath'), $routeParams->get('id'), $routeParams->get('name'));
|
||||
|
||||
if (FileSystem::isFile($path)) {
|
||||
return new FileResponse($path);
|
||||
return new FileResponse($path, headers: ['Cache-Control' => 'private, max-age=31536000, immutable']);
|
||||
}
|
||||
|
||||
throw new FileNotFoundException('Cannot find asset');
|
||||
|
@ -85,7 +85,8 @@ class PageController extends AbstractController
|
||||
}
|
||||
|
||||
if ((($parent = $this->site->findPage($upperLevel)) !== null) && $parent->files()->has($filename)) {
|
||||
return new FileResponse($parent->files()->get($filename)->path());
|
||||
$file = $parent->files()->get($filename);
|
||||
return new FileResponse($file->path(), headers: ['ETag' => $file->hash(), 'Last-Modified' => gmdate('D, d M Y H:i:s T', $file->lastModifiedTime())]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -218,7 +218,7 @@ class UsersController extends AbstractController
|
||||
$path = FileSystem::joinPaths($this->config->get('system.users.paths.images'), $routeParams->get('image'));
|
||||
|
||||
if (FileSystem::isFile($path)) {
|
||||
return new FileResponse($path, headers: ['Cache-Control' => 'max-age=31536000, private']);
|
||||
return new FileResponse($path, headers: ['Cache-Control' => 'private, max-age=31536000, immutable']);
|
||||
}
|
||||
|
||||
throw new FileNotFoundException('Cannot find asset');
|
||||
|
Loading…
x
Reference in New Issue
Block a user