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>
<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
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.
