Try caching images client side
Posted by Haji on .
I am a layman with regard to server administration, but I think the user's browser should be caching the images from the manual project, and I think it is currently not doing that, due to missing header directives.
If implemented, this might reduce load on your server, and also result in a better experience for the user, since a full network fetch doesn't have to be performed when navigating to pages that were already visited, if the images are in the cache.
Instructions from ai (if it helps):
The image.php endpoint needs a Cache-Control response header with the public and max-age directives set, plus an ETag header so the browser can revalidate.
(Server side)
# In .htaccess or vhost config for image.php
<FilesMatch "image\.php">
Header set Cache-Control "public, max-age=86400"
# AND make the PHP script emit an ETag or Last-Modified
</FilesMatch>
On the PHP side, the script needs to emit at least one validator
header("ETag: \"" . md5($imageId . $page . $destDPI) . "\"");
header("Cache-Control: public, max-age=86400");
