WebPagetest Forums
Long Expires/max-age dates, why its suggested? - Printable Version

+- WebPagetest Forums (https://www.webpagetest.org/forums)
+-- Forum: Web Performance (/forumdisplay.php?fid=3)
+--- Forum: Optimization Discussions (/forumdisplay.php?fid=5)
+--- Thread: Long Expires/max-age dates, why its suggested? (/showthread.php?tid=13299)



Long Expires/max-age dates, why its suggested? - postcd - 10-15-2014 01:15 AM

Hi, I found on many places people suggest having like 1 month or 1 year expiration dates on images. So browser cache it for long time..

BUT I would think its better to have image expiration time like 5 minutes. WHY? Because if i modiffy some image i want users to see modiffied image quickly, not have old image cached maybe weeks on their browser cache.. (i know i can change image name, but i not always want to rename it)

While i set 5 minutes expiry date, i believe after this time browser asks server if that image modiffication date changed (tru last-Modiffied or etag). If image mod. date not changed, then its again served from browser cache next 5 minutes? (is that so?) So no bandwidth/performance loss, but i know people will see fresh images..? Thank you


RE: Long Expires/max-age dates, why its suggested? - pmeenan - 10-17-2014 01:25 AM

The long expires are recommended explicitly because it is recommended that you change the file names every time the files change.

While an if-modified check won't use bandwidth, the round trip to ask the server is really expensive for performance (and often as long as downloading the resource itself) so there is a big performance loss in that case.

If you can't rename the images when they change there isn't much you can do, it's just something you should be aware of.