Skip to content

Commit

Permalink
Add cache busting for downloaded resources
Browse files Browse the repository at this point in the history
  • Loading branch information
fheft committed Nov 9, 2022
1 parent 6346ae5 commit 4ce22dc
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/js/export.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import { handler } from "flyps";
handler("export/download", (_, __, tale) => downloadAll(tale));

const downloadAll = tale => {
const cacheBust = "?t=" + new Date().valueOf();
Promise.all([
fetch("/viewer.html").then(response => response.text()),
fetch("/js/viewer.js").then(response => response.text()),
fetch("/css/viewer.css").then(response => response.text()),
fetchAsDataURL(`/editor/${tale.slug}/${tale["file-path"]}`),
fetch(`/viewer.html${cacheBust}`).then(response => response.text()),
fetch(`/js/viewer.js${cacheBust}`).then(response => response.text()),
fetch(`/css/viewer.css${cacheBust}`).then(response => response.text()),
fetchAsDataURL(`/editor/${tale.slug}/${tale["file-path"]}${cacheBust}`),
]).then(([template, script, style, posterBase64]) => {
const doc = template
.replace("{{title}}", () => tale.name)
Expand Down

0 comments on commit 4ce22dc

Please sign in to comment.