Remix Utils - v9.3.1
    Preparing search index...

    Module Client/Cache Assets

    Note

    Install using bunx shadcn@latest add @remix-utils/cache-assets.

    Note

    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.client file and add this:

    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 is the name of the Cache object to use, the default value is assets.
    • buildPath is 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.js you pass the same value to cacheAssets or it will not find your JS files.

    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
    });

    Interfaces

    CacheAssetsOptions

    Functions

    cacheAssets