For the image of the site, each time you open the page to re-download the picture, slow not to say, but also a waste of traffic. Then you need to use the cache to force the browser to cache the picture file
Cache files, ask the website to visit several degrees, reduce traffic consumption, now provides 2 cache code
Open the. htaccess file, and write the following code
Method one: Unified cache duration
<filesmatch ". (FLV|GIF|JPG|JPEG|PNG|ICO|TXT|SWF|PDF|SWF|JS) $ ">header set Cache-control" max-age=2592000 "</FilesMatch>
Method two: Cache duration by different file types
<ifmodule mod_expires.c>expiresactive onexpiresbytype image/jpg "Access 1 Year" Expiresbytype image/jpeg "Access 1 Year ' Expiresbytype image/gif ' access 1 year ' Expiresbytype image/png ' access 1 year ' Expiresbytype text/css ' access 1 month ' Expiresbytype text/html "Access 1 month" Expiresbytype application/pdf "Access 1 month" Expiresbytype Text/x-javascript " Access 1 Month "Expiresbytype Application/x-shockwave-flash" Access 1 month "Expiresbytype Image/x-icon" Access 1 Year " ExpiresDefault "Access 1 month" #默认文件缓存时长, with caution </IfModule>
Attention:
ExpiresDefault "Access 1 month", the default file cache length, use caution, otherwise your methods will be invalidated, such as record browsing volume, you must F5 refresh the page to
Extended reading:
How to create the. htaccess file?
Download a. htaccess file
Original address: http://cssteach.com/show-20-113.html
Use. htaccess for browser picture file caching