I have a site that display a large number of small images (all gif files) and I want to write a htaccess file that I can use to instruct a browser to cache all images for a period of time.
The code within the htaccess file is:
Code:
<FilesMatch "\.(gif$">
Header set Cache-Control "max-age=604800, public"
</FilesMatch>
I think the above code is correct but I am not sure if I place the file in the directory where all the gif images are located or in the root of the site.
From what I understand of htaccess files, placing it in the root is guaranteed to work (htaccess files are processed recursively, so it applies to ALL files and subdirectories).
I'm not sure if placing it in the images folder would work, BUT if it did it would do the same things as the first method since you've already written code to ONLY apply to gifs.
So, placing it in the root would be best, though just be sure you don't overwrite any current htaccess file.
Bookmarks