Knowledge base
1000 FAQs, 500 tutorials and explanatory videos. Here, there are only solutions!
Use the If-Modified-Since HTTP header
This guide concerns the HTTP header "If-Modified-Since" used to check if a resource has been modified since the last time it was retrieved by a client. This helps save bandwidth and speed up page loading by avoiding the retransmission of unchanged static resources.
Using the Header
Here's how you can use it using directives from the mod_expires module in the .htaccess file at the root of your site directory (/web or /sites/domain.xyz, for example):
- Open or create the .htaccess file at the root
- Enter the following code:
<IfModule mod_expires.c> - Then enter your commands, for example:
ExpiresActive On
ExpiresByType text/html "access plus 1 week"
ExpiresByType image/jpeg "access plus 1 month"
ExpiresByType text/css "access plus 1 month"
ExpiresByType application/javascript "access plus 1 month"These directives set the expiration duration for specific resources. In this example, HTML files are cached for one week, JPEG images, CSS files, and JavaScript files are cached for one month. You can adjust these values as needed. - Finish by closing the tag:
</IfModule> - Save the .htaccess file
Link to this FAQ: