mirror of
https://github.com/aureliendavid/rsspreview.git
synced 2025-08-25 12:55:35 +00:00
don't cache modified requests
This commit is contained in:
parent
6d2b0627fe
commit
a83dad4fe0
@ -3,13 +3,31 @@ function detectFeed(event) {
|
||||
|
||||
// force application/rss+xml to text/xml so the browser displays it instead of downloading
|
||||
|
||||
var isfeed = false;
|
||||
|
||||
for (var header of event.responseHeaders) {
|
||||
if (header.name.toLowerCase() == "content-type") {
|
||||
header.value = header.value.replace(/application\/(rss|atom)\+xml/,'text/xml');
|
||||
isfeed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (isfeed) {
|
||||
|
||||
for (var i = 0; i < event.responseHeaders.length; i++) {
|
||||
if (event.responseHeaders[i].name.toLowerCase() == "cache-control") {
|
||||
event.responseHeaders.splice(i, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// don't cache requests we modified
|
||||
// otherwise on reload the content-type won't be modified again
|
||||
event.responseHeaders.push({ name : "Cache-Control", value : "no-cache, no-store, must-revalidate" });
|
||||
|
||||
}
|
||||
|
||||
return {
|
||||
responseHeaders: event.responseHeaders
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user