Open uskov-dev opened 6 months ago
Remove file extensions from globPatterns, for example, you can remove mp3
and mp4
extensions, then add a new runtime caching handler:
{
urlPattern: ({ url, sameOrigin }) => sameOrigin && /\.(mp3|mp4)$/.test(url.pathname),
handler: 'StaleWhileRevalidate',
options: {
cacheName: 'mp-cache',
expiration: {
maxEntries: 10,
maxAgeSeconds: 60 * 60 * 24 * 365,
},
cacheableResponse: {
statuses: [200],
},
},
}
Hello. Please tell me the URLs of media, pictures and audio are coming from my server. I'm trying to cache them so that when I go to the main page after they come from the server, they are immediately cached without going to other pages. Here is my config.
Here is the code that comes
The most important thing is that text data is cached, but it does not cache media files, it caches them only if I go to the page on which the media files will be located and caches them. But I need that as soon as I go to the main page for the first time and receive data from the server, all the media files that are sent in json are automatically cached.
If you build with local media resources, then everything is fine, but media coming from the server is not cached and that’s it.