nrenner / brouter-web

Web client for BRouter, a routing engine based on OpenStreetMap
https://brouter.de/brouter-web/
MIT License
363 stars 69 forks source link

Changes in profiles & cache #749

Open EssBee59 opened 1 year ago

EssBee59 commented 1 year ago

Hello, today a change in a profile on the server side is not visible in brouter-web bevore a cache expiration (can be very long) or a manual "cache-clear" in the browser. As this behaviour is some times not comfortable, I wanted to discuss a "cache deactivation".

A local test with a minor change in Utils.js was ok using windows-edge ( not tested with other browsers!) BR.Util = { get: function (url, cb) { var xhr = new XMLHttpRequest();
xhr.open('GET', url, true); console.log("setRequestHeader NO CAHE utils.js "); xhr.setRequestHeader("Cache-Control", "no-cache, no-store, must-revalidate"); xhr.onload = function () {

regards EssBee

abrensch commented 1 year ago

I added a no-cache header on the server-side in nginx.conf:

location /brouter/profiles2 { autoindex on; autoindex_localtime on; add_header Cache-Control "no-cache, no-store, must-revalidate"; try_files $uri $uri/ =404; }

It is delivered as expected, not sure yet if it solves the problem, but chances are

nrenner commented 1 year ago

Thanks, I was going to suggest to add this on the server side, as there are other resources we might want to update without a release (e.g. config.js, don't have a definitive list yet), that are requested in different ways, some outside our control.

I think it would be better to remove no-store, as it completely disables caching. Using only no-cache, and maybe must-revalidate as a fallback, should be sufficient, as they always check for a newer version with a small HEAD request first and only use the cache if there isn't one.

EssBee59 commented 1 year ago

Very good solution Arndt, a retest was successful! But before closing the issue, we could afford to test the change proposed by Norbert? Regards