greatfire / redirect-when-blocked

Redirect your users to another URL if they can't reach your website
MIT License
95 stars 29 forks source link

cache problem #6

Closed greatfire-martin closed 9 years ago

greatfire-martin commented 9 years ago

The .appcache file is served with a "Cache-Control: max-age=0" header so that browsers will always check whether there's a newer version. The .appcache file contains an md5 hash in a comment which is generated based on the file contents in the RWB directory. The effect should be that whenever RWB code or data changes, browsers update their app cache. However, there's a problem. The cached page is itself cached by the CDN. This means that in some instances the browser will reload the application cache but will replace it with a cached version (at the CDN level) of the older page. When the CDN version is replaced, the application cache no longer will refresh it.

Thinking about solutions..

greatfire-martin commented 9 years ago

Attempting a fix to this by including the hash as a query parameter to the app cache file. If the hash sent from the cached page does not match the hash of the app cache file, the app cache file will output a timestamp to force an update. This should make the browser attempt to load a new version until it gets one which matches the app cache file.

greatfire-martin commented 9 years ago

Seems to be working