Skip to content
This repository has been archived by the owner on May 2, 2024. It is now read-only.

runtimeCaching option #16

Closed
desaintflorent opened this issue Jun 22, 2022 · 5 comments
Closed

runtimeCaching option #16

desaintflorent opened this issue Jun 22, 2022 · 5 comments
Assignees
Labels
enhancement New feature or request

Comments

@desaintflorent
Copy link

Hi there, I'm using the runtimeCaching option with workbox because my images are from a different domain.
I can see that workbox extra options are not supported for this module, could I use this module and still cache images from different domain ?

@kevinmarrec
Copy link
Owner

Hi @desaintflorent , what would you need as configuration to achieve your goal ? Would you have a piece of code of the resulting worker file you want to have it working ?

@desaintflorent
Copy link
Author

desaintflorent commented Jun 22, 2022

That is what I'm using right now with the official nuxt pwa module :

workbox: {
		suffix: "v1",
		runtimeCaching: [
			{
				urlPattern: "http://domain.com/api/.*",
				handler: "networkFirst",
				method: "GET",
				strategyOptions: {
					cacheName: "api",
					cacheableResponse: { statuses: [0, 200] },
				},
			},
			{
				urlPattern: "http://files.domain.com/.*",
				handler: "staleWhileRevalidate",
				strategyOptions: {
					cacheName: "images",
					cacheExpiration: {
						maxEntries: 30,
						maxAgeSeconds: 300, //60 * 60// 1h
					},
					cacheableResponse: { statuses: [0, 200] },
				},
			},
		],
	},

@kevinmarrec
Copy link
Owner

kevinmarrec commented Jun 22, 2022

Great, I'll work on this. Do you need the suffix option too ? I'm not sure what it does but I can anyway check official Nuxt 2 PWA module code.

@kevinmarrec kevinmarrec self-assigned this Jun 22, 2022
@kevinmarrec kevinmarrec added the enhancement New feature or request label Jun 22, 2022
@kevinmarrec
Copy link
Owner

@desaintflorent I'm gonna add support for custom workbox template in which you'll be able to fully customize your runtime caching.

We may add module options later on but I want first to provide a way to fully customize the worker with own template first.

@desaintflorent
Copy link
Author

Ok great ! keep me updated 🙌

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants