Welcome Guest, Not a member yet? Register   Sign In
how to image caching?
#1

[eluser]melpuggi[/eluser]
hello,

i use dynamic pages like "images/1.jpg" for displaying images.

i want to cache images for browsers

look my headers

Code:
$expires_gmt = gmdate("D, d M Y H:i:s", time() + (60 * 60 * 24 * 3) )." GMT";
$modified_gmt = gmdate("D, d M Y H:i:s", time() + (3600 * -1 * 24 * 365) )." GMT";
$mime = "jpeg"; // gif or png
header("Pragma : public");
header("Expires: $expires_gmt");
header("Last-Modified: $modified_gmt");
header("Cache-Control: private, max-age=".(60 * 60 * 24 * 3)."");
header("Content-Length: $result->image_link_size" );
header("Content-Type: image/$mime" );

but firefox does not cache my images and display pages in 4 or 5 second.

ie cache them and display pages in 1 or 2 second.

what is my problem?
#2

[eluser]Nick Husher[/eluser]
How are you serving your images? Really, these settings should be in your Apache configs or .htaccess.
#3

[eluser]Crazy LionHeart[/eluser]
In .htaccess add:
Activate apache cache
Code:
ExpiresActive on
Cache gif for 1 day at last access
Code:
ExpiresByType image/gif A2592000
In this example set cache .gif for one day at last access. Also you may set cache at last modified - M2592000. After Modifer (A/M) you set how many second server must cache data.




Theme © iAndrew 2016 - Forum software by © MyBB