Cache: Add cache-control headers with revalidation to ensure checksum consistency #9

Merged
Bart van der Braak merged 2 commits from cache-revalidation into main 2024-07-25 16:01:33 +02:00
3 changed files with 11 additions and 3 deletions

View File

@ -1,5 +1,5 @@
FROM php:8.1-apache FROM php:8.1-apache
RUN a2enmod proxy && a2enmod rewrite RUN a2enmod proxy && a2enmod rewrite && a2enmod headers
EXPOSE 80 EXPOSE 80

View File

@ -9,7 +9,7 @@ System requirements:
* PHP 7+ * PHP 7+
To run the site: To run the site:
* `a2enmod proxy` and `a2enmod rewrite` to enable proxy pass and rewrite rules * `a2enmod proxy`, `a2enmod rewrite` and `a2enmod headers` to enable proxy pass, rewrite rules and setting headers
* Add the `000-default.conf` to the `sites-available` * Add the `000-default.conf` to the `sites-available`
### Setup with Docker ### Setup with Docker
@ -18,7 +18,8 @@ To run the website using Docker, follow these steps:
Use the provided `Dockerfile` and `docker-compose.yml` to build and start the containers. Execute the following command: Use the provided `Dockerfile` and `docker-compose.yml` to build and start the containers. Execute the following command:
```sh ```sh
docker compose up docker compose up --build
# --build makes sure to rebuild the image in case there were changes to the Dockerfile
``` ```
Once the containers are up and running, you can access the website on port `8080`: Once the containers are up and running, you can access the website on port `8080`:

View File

@ -26,6 +26,13 @@
SetHandler application/x-httpd-php SetHandler application/x-httpd-php
</FilesMatch> </FilesMatch>
<IfModule mod_headers.c>
# Make sure that CDN77 revalidates every 60 sec to prevent cache drift between builds and their shasum counterpart
<FilesMatch "\.(xz|msi|msix|exe|gz|bz2|dmg|sha256)$">
Header set Cache-Control "public, max-age=60, must-revalidate"
</FilesMatch>
</IfModule>
ProxyPass /admin/ws ws://localhost:8010/ws ProxyPass /admin/ws ws://localhost:8010/ws
ProxyPassReverse /admin/ws ws://localhost:8010/ws ProxyPassReverse /admin/ws ws://localhost:8010/ws
ProxyPass /admin/ http://localhost:8010/ ProxyPass /admin/ http://localhost:8010/