Forum Moderators: phranque

Message Too Old, No Replies

Correct Location For Cache Rules In htaccess File

         

Jennnnn

5:23 pm on May 9, 2019 (gmt 0)

5+ Year Member Top Contributors Of The Month



Where should cache control rules be located in my htaccess file? At the top?

My htaccess file starts like this:

1
2 RewriteOptions inherit
3 RewriteCond %{HTTPS} off

Should the cache control rules be added above line 2? Thanks!

phranque

8:16 pm on May 9, 2019 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



You should place all the cache control directives together in a location that makes it easiest for you to maintain the .htaccess file.

lucy24

11:36 pm on May 9, 2019 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



Where should cache control rules be located in my htaccess file? At the top?
In Apache, each module is an island. The server doesn’t care whether the directives for module A are before module B, after module B ... or randomly mixed together. Put them where it is most intuitively comfortable for you. I like to put single-line directives--such as caching rules, options, error documents and the like--at the beginning, before getting into the modules like setenvif or rewrite that each will have a whole lot of rules.