www.webdeveloper.com
Results 1 to 3 of 3

Thread: Caching using a htaccess file

  1. #1
    Join Date
    Dec 2002
    Location
    Warwickshire, England
    Posts
    182

    Caching using a htaccess file

    Hi all,

    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.

    Can anyone please advise.

  2. #2
    Join Date
    Jul 2006
    Posts
    128
    Hi Dereck,

    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.

  3. #3
    Join Date
    Apr 2011
    Location
    I live in the pinaple under the sea
    Posts
    107
    I had heard about the cache-manifest, it is new to html5, it basically cache files like js and css, but I'm not sure if it can also cache images.

    try to check this link for more info http://www.w3.org/TR/html5/offline.html

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles