Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Service Worker gets cached #138

Closed
cloudlena opened this issue Feb 12, 2018 · 6 comments
Closed

Service Worker gets cached #138

cloudlena opened this issue Feb 12, 2018 · 6 comments
Labels
enhancement A new feature or request

Comments

@cloudlena
Copy link
Contributor

cloudlena commented Feb 12, 2018

What version of Cloud Foundry and CF CLI are you using? (i.e. What is the output of running cf curl /v2/info && cf version?

CLI 6.34.1 and CF 2.100.0

What version of the buildpack you are using?

1.4.22

If you were attempting to accomplish a task, what was it you were attempting to do?

Push an app created with create-react-app.

What did you expect to happen?

I expect the deployed service worker to be refreshed when I push a new version of the app.

What was the actual behavior?

The service worker gets cached for a very long time which causes my app to remain stale, even if I push new versions. I'm guessing that this is the same for anybody who uses service workers.

I'm guessing that we would need to add something like

location ~* ((serviceworker|service-worker)\.js)$ {
  add_header 'Cache-Control' 'no-store, no-cache, must-revalidate, proxy-revalidate, max-age=0';
  expires off;
  proxy_no_cache 1;
}

to the nginx config template.

The problem is described here.

The solution to this problem cor create-react-app for different hosting providers is described here but I'm unsure how I would apply this to Cloud Foundry since providing one's own nginx.conf is deprecated.

@cf-gitbot
Copy link

We have created an issue in Pivotal Tracker to manage this:

https://www.pivotaltracker.com/story/show/155135355

The labels on this github issue will be updated when the story is started.

@sclevine
Copy link
Contributor

I suggest one of the following options:

  1. Use the experimental NGINX buildpack: https://github.com/cloudfoundry/nginx-buildpack
  2. Use the location_include directive in the Staticfile.

The staticfile buildpack is intended to be used to host static content, not web applications.

(@dgodd)

@cloudlena
Copy link
Contributor Author

Thanks, @sclevine. Using location_include is a good idea. I'll give it a try. However, I still think it would still be a good thing to provide a way for users to disable caching for certain locations.

@patrickliangli
Copy link

@mastertinner , did you find a solution to this problem? I am also having the same issue.

@cloudlena
Copy link
Contributor Author

@patrickliangli, I haven't tried anything specific yet. As far as I can tell, putting my code snippet from above into a location_include should work though.

@sclevine sclevine added the enhancement A new feature or request label Mar 12, 2018
@astrieanna
Copy link
Contributor

This seems to have been resolved by either of the two options @sclevine gave.

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

No branches or pull requests

5 participants