feat: add support for static asset caching (#133)

This commit is contained in:
Sylvain Cau
2022-03-16 16:49:47 +01:00
committed by GitHub
parent 8aa1b250b8
commit 6cbcc27646
9 changed files with 93 additions and 20 deletions
+12
View File
@@ -1 +1,13 @@
export const INTERNAL_PREFIX = "/_frsh";
export const STATIC_PREFIX = `/static`;
export const IS_BROWSER = typeof document !== "undefined";
/**
* Return a path "hashed" with the BUILD_ID. of a static file
* Such path will be served by the server with a Cache-Control of 1 year.
* @param path a path to a file in the static folder asset. e.g. /style.css
*/
export function asset(path: string) {
return `${INTERNAL_PREFIX}${STATIC_PREFIX}/${__FRSH_BUILD_ID}${path}`;
}