Skip to content

Instantly share code, notes, and snippets.

@colinaaa
Created March 24, 2020 08:52
Show Gist options
  • Save colinaaa/2f916c1eab148b59f0cf9cec48782f8d to your computer and use it in GitHub Desktop.
Save colinaaa/2f916c1eab148b59f0cf9cec48782f8d to your computer and use it in GitHub Desktop.
refresh pdf when it changed in FireFox
let lastModifiedAt = new Date();
fetch(document.URL, {
mode: 'cors',
headers: {
'if-modified-since': lastUpdatedAt.toUTCString(),
}
})
.then(resp => {
if(resp.status === 304) {
lastModifiedAt = new Date();
location.reload();
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment