diff --git a/banners.php b/banners.php index ef75c2cb..f08d3b03 100644 --- a/banners.php +++ b/banners.php @@ -1,16 +1,8 @@ \ No newline at end of file +$filename = $files[array_rand($files)]; +header("Location: /banners/$filename", true, 307); +header('Cache-Control: no-cache'); diff --git a/docker/nginx/leftypol.conf b/docker/nginx/leftypol.conf index cdb28076..b531e736 100644 --- a/docker/nginx/leftypol.conf +++ b/docker/nginx/leftypol.conf @@ -20,33 +20,17 @@ server { # Expire rules for static content # Media: images, icons, video, audio, HTC - location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { - expires 1M; - access_log off; + location ~* \.(?:jpg|jpeg|gif|png|webp|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { log_not_found off; - add_header Cache-Control "public"; + # Public cache, never changes until max-age expires, max-age of 1 month, can still be served while being + # revalidated or if the server is erroring for 1 day. + add_header Cache-Control "public, immutable, max-age=2592000, stale-while-revalidate=86400, stale-if-error=86400"; } # CSS and Javascript location ~* \.(?:css|js)$ { - expires 1y; - access_log off; log_not_found off; - add_header Cache-Control "public"; - } - # Expire rules for static content - # Media: images, icons, video, audio, HTC - location ~* \.(?:jpg|jpeg|gif|png|ico|cur|gz|svg|svgz|mp4|ogg|ogv|webm|htc)$ { - expires 1M; - access_log off; - log_not_found off; - add_header Cache-Control "public"; - } - # CSS and Javascript - location ~* \.(?:css|js)$ { - expires 1y; - access_log off; - log_not_found off; - add_header Cache-Control "public"; + # Public cache, max-age of 1 year, can still be served while being revalidated or if the server is erroring for 1 day. + add_header Cache-Control "public, max-age=31536000, stale-while-revalidate=86400, stale-if-error=86400"; } location ~* \.(html)$ { diff --git a/docker/php/bootstrap.sh b/docker/php/bootstrap.sh index e94dcf28..131a7000 100755 --- a/docker/php/bootstrap.sh +++ b/docker/php/bootstrap.sh @@ -25,7 +25,6 @@ fi # Link the entrypoints from the exposed directory. ln -nfs \ - /code/banners/ \ /code/tools/ \ /code/walls/ \ /code/*.php \ @@ -36,6 +35,7 @@ ln -nfs \ # Static files accessible from the webserver must be copied. cp -ur /code/static /var/www/ cp -ur /code/stylesheets /var/www/ +cp -ur /code/banners /var/www/ # Ensure correct permissions are set, since this might be bind mount. chown www-data /var/www