Add and Disable ETags through .htaccess

How to add and disable ETags through

.htaccess

? An ETag, or entity tag, is part of HTTP and it provides a unique identifier for the resource being supplied.

Use this code to setup ETags on your server, using following

.htaccess

:

FileETag MTime Size
<ifmodule mod_expires.c>
  <filesmatch "\.(jpg|gif|png|css|js)$">
       ExpiresActive on
       ExpiresDefault "access plus 1 year"
   </filesmatch>
</ifmodule>

Though sometimes developer want to be disable ETags from headers. To disable ETags, make sure to include following snippet in your

.htaccess file

:

Header unset ETag
FileETag None

Something like this:

All PHP Scripts on this website are provided by phpscripts4u.com where you can find all the latest PHP code snippets, plugins and libraries.

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>