Skip to content

Commit 5cd2e53

Browse files
authored
Merge pull request #3245 from processing/cache-busting
add cache busting to assets in preview
2 parents 184448c + 340600a commit 5cd2e53

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

client/modules/Preview/previewIndex.jsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,19 @@ const App = () => {
5252
}
5353
}
5454

55+
function addCacheBustingToAssets(files) {
56+
const timestamp = new Date().getTime();
57+
return files.map((file) => {
58+
if (file.url) {
59+
return {
60+
...file,
61+
url: `${file.url}?v=${timestamp}`
62+
};
63+
}
64+
return file;
65+
});
66+
}
67+
5568
useEffect(() => {
5669
const unsubscribe = listen(handleMessageEvent);
5770
return function cleanup() {
@@ -62,7 +75,7 @@ const App = () => {
6275
<React.Fragment>
6376
<GlobalStyle />
6477
<EmbedFrame
65-
files={state}
78+
files={addCacheBustingToAssets(state)}
6679
isPlaying={isPlaying}
6780
basePath={basePath}
6881
gridOutput={gridOutput}

0 commit comments

Comments
 (0)