.htaccess for Apache 2.4 eTags and 304 cache Print this Article
This article assumes you have Apache 2.4 and its required modules installed ( Headers / Expires / Deflate )
The first step is to add the headers section; this will enable etags for all files and then remove etags for specific files that are usually compressed and added to the -gzip etag bug.
FileETag MTime Size
Header unset ETag
Mode expire sets far date expires to specific file types. You can change these based on your needs.
ExpiresByType image/jpg "access 2 week"
ExpiresByType image/jpeg "access 2 week"
ExpiresByType image/gif "access 2 week"
ExpiresByType image/png "access 2 week"
ExpiresByType image/svg+xml "access 2 week"
ExpiresByType text/css "access 1 month"
ExpiresByType text/html "access 1 week"
ExpiresByType application/pdf "access 1 month"
ExpiresByType image/x-icon "access 1 year"
ExpiresDefault "access 1 month"
#DeflateAlterETag NoChange #enable in apache 2.5
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE image/svg+xml
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/octet-stream #font
With the above settings, you should be able to serve all your content with compression, etags on a clustered settup.
Written - December 30th 2016 by Jon Wong
Was this answer helpful?
404 Errors are common errors when a user has deleted the source content. In many cases a website...
The 403 Forbidden error is an HTTP status code that means that accessing the page or resource you...
The 500 Internal Server Error is a very general HTTP status code that means something has gone...
The 503 Service Unavailable error is a server-side error, meaning the problem is usually with the...
We have had a few request to block foreign ips from accessing clients websites due to abuse.We...