Set cache-control on thumbnails
This commit is contained in:
parent
92315f2f0c
commit
70ec2caa93
6
cache/.htaccess
vendored
6
cache/.htaccess
vendored
@ -9,3 +9,9 @@ RewriteEngine on
|
|||||||
RewriteCond %{REQUEST_FILENAME} !-d
|
RewriteCond %{REQUEST_FILENAME} !-d
|
||||||
RewriteCond %{REQUEST_FILENAME} !-f
|
RewriteCond %{REQUEST_FILENAME} !-f
|
||||||
RewriteRule ^(.*)/?$ handle_404.php?file=$1 [QSA,L]
|
RewriteRule ^(.*)/?$ handle_404.php?file=$1 [QSA,L]
|
||||||
|
|
||||||
|
<IfModule mod_headers.c>
|
||||||
|
<filesMatch ".jpg$">
|
||||||
|
Header set Cache-Control "max-age=604800, public"
|
||||||
|
</filesMatch>
|
||||||
|
</IfModule>
|
6
cache/handle_404.php
vendored
6
cache/handle_404.php
vendored
@ -9,6 +9,7 @@
|
|||||||
require_once __DIR__ . "/../required.php";
|
require_once __DIR__ . "/../required.php";
|
||||||
|
|
||||||
header("Content-Type: text/plain;utf-8");
|
header("Content-Type: text/plain;utf-8");
|
||||||
|
header("Cache-Control: max-age=" . (60 * 60 * 24 * 7));
|
||||||
|
|
||||||
$urlparts = explode("/", $_GET['file']);
|
$urlparts = explode("/", $_GET['file']);
|
||||||
$fileparts = explode(".", end($urlparts));
|
$fileparts = explode(".", end($urlparts));
|
||||||
@ -24,9 +25,8 @@ if (!preg_match("/^[A-Za-z0-9\-!_]+$/", $fileparts[0])) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (strpos($fileparts[0], "SHA1_") === 0) {
|
if (strpos($fileparts[0], "SHA1_") === 0) {
|
||||||
$hash = str_replace("SHA1_", "", $fileparts[0]);
|
if ($database->has("imagecache", ["hash" => $fileparts[0]])) {
|
||||||
if ($database->has("imagecache", ["hash" => $hash])) {
|
$url = $database->get("imagecache", 'url', ["hash" => $fileparts[0]]);
|
||||||
$url = $database->get("imagecache", 'url', ["hash" => $hash]);
|
|
||||||
echo $url;
|
echo $url;
|
||||||
} else {
|
} else {
|
||||||
http_response_code(404);
|
http_response_code(404);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user