Akshay Shrivastav
Akshay Shrivastav

Reputation: 1227

is disabling ETAG and Last-Modifed a good option .htaccess

I'm using the below code for caching of files in .htaccess

<IfModule mod_headers.c>
    <filesMatch "\.(ico|jpe?g|png|gif|swf)$">
        Header set Cache-Control "public"
    </filesMatch>
    <filesMatch "\.(css|scss)$">
        Header set Cache-Control "public"
    </filesMatch>
    <filesMatch "\.(js)$">
        Header set Cache-Control "private"
    </filesMatch>
    <filesMatch "\.(x?html?|xml)$">
        Header set Cache-Control "private, must-revalidate"
    </filesMatch>
    #Header unset ETag
    #Header unset Last-Modified
</IfModule>

I'm a bit confused if i should comment the #Header unset ETag and #Header unset Last-Modified or not

below is my default.conf file on apache

CacheQuickHandler off                                                                                              
CacheLock on
CacheLockPath /tmp/mod_cache-lock
CacheLockMaxAge 5                                                                                                  
CacheIgnoreHeaders Set-Cookie
<Location />                                                                                                       
CacheEnable disk                                                                                                   
CacheHeader on                                                                                                     
CacheDefaultExpire 600                                                                                             
CacheMaxExpire 86400
CacheLastModifiedFactor 0.5                                                                                        
ExpiresActive on                                                                                                   
ExpiresDefault "access plus 1 week"                                                                                
ExpiresByType image/x-icon "access plus 1 month"                                                                   
ExpiresByType image/jpeg "access plus 1 year"                                                                      
ExpiresByType image/png "access plus 1 month"                                                                      
ExpiresByType text/css "access plus 1 month"                                                                       
ExpiresByType text/javascript "access plus 1 month"
ExpiresByType application/ld+json "acesss plus 1 day"                                                              
# This part sets the expires for the fonts                                                                         
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType image/svg+xml "access plus 1 year"                                                                   
#Header merge Cache-Control public
FileETag All                                                                                                       
</Location>

Kindly anyone help me with this confusion what should i do to achieve maximum and best compression.

Upvotes: 0

Views: 850

Answers (1)

Jonathan
Jonathan

Reputation: 999

Etag and Last-Modified have nothing to do with compression, they are cache'ing options. Which is OK to unset anyway because they conflict with Cache-Control, which is a better cache method. So yes, you may disable it.

If you are looking for compression, look into Apache's mod_deflate, mod_gzip or mod_brotli.

Upvotes: 2

Related Questions