Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Clear OidcServiceWorker cache every build #1310

Closed
ozanmanav opened this issue Feb 28, 2024 · 7 comments · May be fixed by #1312
Closed

Clear OidcServiceWorker cache every build #1310

ozanmanav opened this issue Feb 28, 2024 · 7 comments · May be fixed by #1312

Comments

@ozanmanav
Copy link

Issue and Steps to Reproduce

Since we have IIS Load balancer in our environment, the js files in dist/build need to be renewed every time there is a build. Since the file name remains the same, it remains cached. Does anyone have a solution suggestion for this?

Versions

7.19.0

Screenshots

image

Expected

A -postfix can be added to the OidcServiceWorker and OidcTrustedDomain files in every build. Or something can be done to reset caching.

Actual

Currently, the file remains cached because it has not changed.

@guillaume-chervet
Copy link
Contributor

hi @ozanmanav ,

Thank you for your issue.
I think I can try to add natively a query string when calling service worker file.

Like :
ServiceWorker.js?v=4.5.3
What do you think about it?
I never encourter the problem before, i do not know why.

@ozanmanav
Copy link
Author

hi @ozanmanav ,

Thank you for your issue. I think I can try to add natively a query string when calling service worker file.

Like : ServiceWorker.js?v=4.5.3 What do you think about it? I never encourter the problem before, i do not know why.

Thanks for answer. Yeah maybe we can try add this version to there automatically. Not important version number just change file name maybe for every build, so we should able to set this from some where

@ozanmanav
Copy link
Author

ozanmanav commented Feb 28, 2024

@guillaume-chervet For now, I did a workaround like this: I wrote the commit hash of the latest version of the application to localstorage and added something like clearing the serviceworker cache if the application changes. But of course this does not apply to OidcTrustedDomains.js.

image

image

@guillaume-chervet
Copy link
Contributor

hi @ozanmanav ,

does v7.19.1-alpha.1372 version solve your problem?
I have added a query string with the version of the library.

@ozanmanav
Copy link
Author

hi @ozanmanav ,

does v7.19.1-alpha.1372 version solve your problem? I have added a query string with the version of the library.

Hey Thanks, Since we will not make any changes to this file without changing the library, this will be the solution. What can we do for OidcTrustedDomains.js? I think we need to do library independent versioning for it because it can change independently.

@pgangwani
Copy link

@ozanmanav @guillaume-chervet :
I am using nginx and wrote Cache-Control: no-cache,must-revalidate for service worker. Isnt that should be doc change too?

@ozanmanav
Copy link
Author

@ozanmanav @guillaume-chervet : I am using nginx and wrote Cache-Control: no-cache,must-revalidate for service worker. Isnt that should be doc change too?

Yeah good point thanks, For IIS, i think we can use disable caching for sw and trusted domains js like this: https://stackoverflow.com/a/15229507/5562701

@guillaume-chervet It looks like you don't need to take any further action for now, I'm closing this issue.

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants