Install using bunx shadcn@latest add @remix-utils/cache-assets.
bunx shadcn@latest add @remix-utils/cache-assets
This can only be run inside entry.client.
entry.client
This function lets you easily cache inside the browser's Cache Storage every JS file built by Remix.
To use it, open your entry.client file and add this:
import { cacheAssets } from "remix-utils/cache-assets";cacheAssets().catch((error) => { // do something with the error, or not}); Copy
import { cacheAssets } from "remix-utils/cache-assets";cacheAssets().catch((error) => { // do something with the error, or not});
The function receives an optional options object with two options:
cacheName
assets
buildPath
/build/
It's important that if you changed your build path in remix.config.js you pass the same value to cacheAssets or it will not find your JS files.
remix.config.js
cacheAssets
The cacheName can be left as is unless you're adding a Service Worker to your app and want to share the cache.
import { cacheAssets } from "remix-utils/cache-assets";cacheAssests({ cacheName: "assets", buildPath: "/build/" }).catch((error) => { // do something with the error, or not}); Copy
import { cacheAssets } from "remix-utils/cache-assets";cacheAssests({ cacheName: "assets", buildPath: "/build/" }).catch((error) => { // do something with the error, or not});
Sergio XalambrÃ
Install using
bunx shadcn@latest add @remix-utils/cache-assets.This can only be run inside
entry.client.This function lets you easily cache inside the browser's Cache Storage every JS file built by Remix.
To use it, open your
entry.clientfile and add this:The function receives an optional options object with two options:
cacheNameis the name of the Cache object to use, the default value isassets.buildPathis the pathname prefix for all Remix built assets, the default value is/build/which is the default build path of Remix itself.It's important that if you changed your build path in
remix.config.jsyou pass the same value tocacheAssetsor it will not find your JS files.The
cacheNamecan be left as is unless you're adding a Service Worker to your app and want to share the cache.Author
Sergio XalambrÃ