refactor: asset caching via query param (#192)
This updates the asset caching to use a cache busting query string, rather than a totally separate path. This makes it safer to apply caching automatically to things like `<img>` tags, as the path does not change anymore.
This commit is contained in:
+1
-1
@@ -134,7 +134,7 @@ Deno.test({
|
||||
assertEquals(res.status, 200);
|
||||
|
||||
// verify the island is revived.
|
||||
const browser = await puppeteer.launch();
|
||||
const browser = await puppeteer.launch({ args: ["--no-sandbox"] });
|
||||
const page = await browser.newPage();
|
||||
|
||||
await page.goto("http://localhost:8000");
|
||||
|
||||
+2
-2
@@ -137,7 +137,7 @@ Deno.test("/static page prerender", async () => {
|
||||
assert(!body.includes(`main.js`));
|
||||
assert(!body.includes(`island-test.js`));
|
||||
assertStringIncludes(body, "<p>This is a static page.</p>");
|
||||
assertStringIncludes(body, `src="/_frsh/static`);
|
||||
assertStringIncludes(body, `src="/image.png?__frsh_c=`);
|
||||
assert(!body.includes("__FRSH_ISLAND_PROPS"));
|
||||
});
|
||||
|
||||
@@ -205,7 +205,7 @@ Deno.test("static file - by 'hashed' path", async () => {
|
||||
const body = await resp.text();
|
||||
const imgFilePath = body.match(/img src="(.*?)"/)?.[1];
|
||||
assert(imgFilePath);
|
||||
assert(imgFilePath.includes(globalThis.__FRSH_BUILD_ID));
|
||||
assert(imgFilePath.includes(`?__frsh_c=${globalThis.__FRSH_BUILD_ID}`));
|
||||
|
||||
// check the static file is served corectly under its cacheable route
|
||||
const resp2 = await router(
|
||||
|
||||
Reference in New Issue
Block a user