In order to speed up my site Telium I created the .htaccess below.  I have a lot of large images on my site so I want browsers to cache as much as possible.  However, when I browse to my web site  with the developer tools open (in Chrome), I see that all of the images on my pages are being re-downloaded every time I refresh.  My .htaccess is located in the root of the web site, and looks like this:# BEGIN Expire headers<ifModule mod_expires.c>  ExpiresActive On  ExpiresDefault access plus 5 seconds  ExpiresByType image/x-icon access plus 2592000 seconds  ExpiresByType image/jpeg access plus 2592000 seconds  ExpiresByType image/png access plus 2592000 seconds  ExpiresByType image/gif access plus 2592000 seconds  ExpiresByType application/x-shockwave-flash access plus 2592000 seconds  ExpiresByType text/css access plus 604800 seconds  ExpiresByType text/javascript access plus 216000 seconds  ExpiresByType application/javascript access plus 216000 seconds  ExpiresByType application/x-javascript access plus 216000 seconds  ExpiresByType text/html access plus 600 seconds  ExpiresByType application/xhtml+xml access plus 600 seconds</ifModule># END Expire headers<ifModule mod_deflate.c>  AddOutputFilterByType DEFLATE text/html text/xml text/css text/plain  AddOutputFilterByType DEFLATE image/svg+xml application/xhtml+xml application/xml  AddOutputFilterByType DEFLATE application/rdf+xml application/rss+xml application/atom+xml  AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript application/json  AddOutputFilterByType DEFLATE application/x-font-ttf application/x-font-otf  AddOutputFilterByType DEFLATE font/truetype font/opentype</ifModule># BEGIN Cache-Control Headers<ifModule mod_headers.c>  <filesMatch .(ico|jpe?g|png|gif|swf)$>    Header set Cache-Control public  </filesMatch>  <filesMatch .(css)$>    Header set Cache-Control public  </filesMatch>  <filesMatch .(js)$># was private      Header set Cache-Control public  </filesMatch>  <filesMatch .(x?html?|php)$>    Header set Cache-Control private, must-revalidate  </filesMatch></ifModule># END Cache-Control HeadersHere is an example of the response headers associated with an image retrieved every time I refresh:Accept-Ranges:bytesCache-Control:publicConnection:Keep-AliveContent-Length:75149Content-Type:image/jpegDate:Thu, 28 May 2015 12:56:46 GMTETag:a9e0dd3-1258d-516beac088af3Expires:Sat, 27 Jun 2015 12:56:46 GMTKeep-Alive:timeout=5Last-Modified:Sat, 23 May 2015 12:11:09 GMTServer:Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_fcgid/2.3.10-devCan someone suggest what I need to change to make the browser cache these images (and text)?Update: After adding max-age the new header is:Accept-Ranges:bytesCache-Control:public, max-age=2592000Connection:Keep-AliveContent-Length:118966Content-Type:image/jpegDate:Thu, 28 May 2015 20:11:33 GMTETag:a9e0de5-1d0b6-516bead2e811cExpires:Sat, 27 Jun 2015 20:11:33 GMTKeep-Alive:timeout=5Last-Modified:Sat, 23 May 2015 12:11:28 GMTServer:Apache/2.4.12 (Unix) OpenSSL/1.0.1e-fips mod_bwlimited/1.4 mod_fcgid/2.3.10-dev
Image max-age / cache-control not being set
images;cache;browsers
You should change...Header set Cache-Control public...to...Header set Cache-Control max-age=x...but replace x with the number of seconds you want any browser that supports HTTP 1.1 to cache the item. The reason why I removed public is because public is the default scope in which caching is applied to (meaning it is applied to browsers and proxies in-between).The if-modified checks and etags as Richhallstoke suggests is useful but requests are still made to the server even to receive a 304 response. Caching with a maximum age set (whether through expires header or cache-control's max-age) means the browser will use the local cache as much as possible until the defined age is reached or a forced refresh is made. This means more bandwidth savings for the client.