Forum Moderators: phranque

Message Too Old, No Replies

caching - best practices

mod_expires, last-modified

         

erinspice

6:18 pm on Feb 22, 2012 (gmt 0)

10+ Year Member



Hello, all! I am writing a small web app that consists solely of static html/javascript in the frontend and mod_perl in the backend which serves up JSON responses for the frontend. I need to ensure that when the static html and javascript files are updated, the user immediately receives fresh copies of the files. Using old javascript code at the same time as new backend code can damage the data. How should I handle this? I need to make sure the browser downloads all files anew every time the modified time on the disk changes, but I will never know what time that is, as this app will be deployed on multiple servers on multiple networks, and updates will be up to the admin of the system.

I have done some research on mod_expires, but it seems this would only affect the expiration date of the resource in the browser's cache and must be set *ahead* of the request at which I need the browser to update its cache, which of course isn't possible in my application.

Is Last-Modified the answer? Do most/all browsers respect this and refresh their cache if Last-Modified changes? If so, how can I cause Apache to send this header? It is not sending the header now.

phranque

10:44 am on Mar 1, 2012 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



i would assume that all modern browsers and any crawlers worth worrying about have long since supported If-Modified-Since/Last-Modified HTTP Request/Response headers.

the details for implementing this have been discussed many times in this forum - for example...

htaccess last-modified usage:
http://www.webmasterworld.com/apache/3173093.htm [webmasterworld.com]
Enabling If-Modified-Since Headers:
http://www.webmasterworld.com/apache/4105446.htm [webmasterworld.com]

microsoft has a HTTP compression and conditional GET test tool:
http://www.microsoft.com/search/Tools/ [microsoft.com]
you might find that useful while testing your implementation.