user1293332
user1293332

Reputation: 53

How disable caching for images in one folder, but enable for all other folders

I have structure

/media
    images
        file1_dis.jpg
        file2_dis.jpg
        .... 
        other_images
           subfolders
               file1_en.jpg
               file2_en.jpg

I want enable caching for all files in subfolders, but disable caching for files in folder /media/images

Structure of site i cant't change.

Now i have code in .htaccess

<FilesMatch "\.(jpg|jpeg|png|gif)$">
    Header set Expires "Thu, 15 Apr 3015 20:00:00 GMT"
</FilesMatch>

its enable caching for all images on my site.

Upvotes: 3

Views: 16174

Answers (2)

yAnTar
yAnTar

Reputation: 4610

1) You should put .htaccess with code

<FilesMatch "\.(jpg|jpeg|png|gif)$">
    Header set Expires "Thu, 15 Apr 3015 20:00:00 GMT"
</FilesMatch>

in folder other_images

2) You can use directive DirectoryMatch

Upvotes: 5

IberoMedia
IberoMedia

Reputation: 2304

insert a file into the subfolder with content you want NOT CACHE as follows

file name

.htaccess

contents of this file:

<IfModule mod_expires.c>
# disable caching forthis directory mod_expires for this directory
ExpiresActive off
</IfModule>

For detailed information: http://static.askapache.com/httpd/modules/mod_expires.c

For MORE detail information: http://www.askapache.com/htaccess/speed-up-sites-with-htaccess-caching.html#mod_expires_Caching_EX-_1

Upvotes: 5

Related Questions