Modules in the .htaccess

How about this code for your .htaccess ? I have inputted them in single individual blocks, but I suppose it’s better to put them in lump like this? Can anyone see any issues with it?

<IfModule mod_expires.c>
ExpiresActive On
ExpiresDefault "access plus 1 year"
ExpiresByType text/html                             "access plus 300 seconds"
ExpiresByType text/css                              "access plus 1 year"
ExpiresByType application/javascript                "access plus 1 year"
ExpiresByType audio/ogg                             "access plus 1 year"
ExpiresByType image/gif                             "access plus 1 year"
ExpiresByType image/jpeg                            "access plus 1 year"
ExpiresByType image/png                             "access plus 1 year"
ExpiresByType video/mp4                             "access plus 1 year"
ExpiresByType video/ogg                             "access plus 1 year"
ExpiresByType video/webm                            "access plus 1 year"
ExpiresByType text/x-component                      "access plus 1 year"
ExpiresByType image/x-icon                          "access plus 1 month"
ExpiresByType application/json                      "access plus 0 seconds"
ExpiresByType application/xml                       "access plus 0 seconds"
ExpiresByType text/xml                              "access plus 0 seconds"
ExpiresByType application/x-web-app-manifest        "access plus 0 seconds"
ExpiresByType text/cache-manifest                   "access plus 0 seconds"
ExpiresByType application/atom                      "access plus 6 hour"
ExpiresByType application/rss                       "access plus 6 hour"
</IfModule>

It makes sense to me to have them all in one block.

You could do away with the <IfModule> which can slow the server a tad. Either your server has mod_expires in which case it’s unnecessary or it doesn’t in which case the whole block is superfluous.

Thanks Gandalf, so nothing to lose by taking off the <IfModule> ?

Provided the module is installed. You’ll get a 500 error if it’s not.

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.