This tutorial explains how to disable ETags completely. In many cases, sending ETag headers negatively impacts performance, as explained by the wizards at Google and Yahoo. This tutorial explains how to disable ETags via .htaccess for your Apache-powered website. Two copy/paste steps and done. Estimated time required: 5 minutes.
Copy & Paste
Quick fix? Grab the code:
# Disable ETags <IfModule mod_headers.c> Header unset ETag </IfModule> FileETag None
That is the basic code required to completely disable ETags. Continue reading for a more elaborate technique and tutorial.
Step 1: Unset ETag and set Cache-Control headers
This step ensures that all ETag headers are unset (first line). Then it sets some basic
Cache-Control headers to help optimize performance. So first step: add the following directives to your site’s root .htaccess file:
<IfModule mod_headers.c> Header unset ETag <filesMatch "\.(ico|jpe?g|png|gif|swf)$"> Header set Cache-Control "max-age=2592000, public" </filesMatch> <filesMatch "\.(css)$"> Header set Cache-Control "max-age=604800, public" </filesMatch> <filesMatch "\.(js)$"> Header set Cache-Control "max-age=216000, private" </filesMatch> <filesMatch "\.(x?html?|php)$"> Header set Cache-Control "max-age=420, private, must-revalidate" </filesMatch> </IfModule>
Cache-Control rules we are using here are pretty basic, so feel free to beef ’em up with something more robust. The main thing here is to unset the ETag header (first line), and then also make sure that you’re sending
Cache-Control headers with each response. The far-future expires headers eliminate any need for ETags.
Step 2: Disable ETags
Now that we’re sending far-future expires headers (previous step), we can disable all ETags that otherwise would have been sent by the server. So last step: add this line after the previous set of rules:
That’s all there is to it. You can verify that ETags are not being sent using an online tool or browser extension that examines request headers. Performance boost, here we come!