Navigation Menu

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

Problem with service workers and stale code #645

Closed
ncrawlins opened this issue Jul 5, 2016 · 26 comments
Closed

Problem with service workers and stale code #645

ncrawlins opened this issue Jul 5, 2016 · 26 comments
Labels

Comments

@ncrawlins
Copy link

Sorry if there is something fundamental I'm missing in the docs, but I can't figure this out. When I build for production and push to the server, the service workers (or app cache maybe?) still serve old versions of the app when I navigate to the production site. If hit CTRL-F5 in Chrome to force refresh, I see the new version of the app, but if I then just hit F5, it will revert to the old version (served by the service workers, I guess?)

Is there something I need to be doing when pushing a new version of the app to production to let the service workers know they need to update their cache?

@gihrig
Copy link
Contributor

gihrig commented Jul 5, 2016

All browsers listed below (Mac OS) run the app in off-line mode as expected. In my local environment, content updates with a new npm run start:production do not appear reliably in all running browsers.

Restarting the browser shows updated content in all browsers.

I'm on Mac OS 10.11.5
Chrome 51.0.2704 - Content not updated with Cmd-R >>> is updated after browser re-start.
FireFox 47.0.1 - Content not updated with Cmd-R >>> is updated after browser re-start.
Safari 9.1.1 - Content updated after Cmd-R (twice)

I don't know if there is a real solution, or if a solution is needed. But, in case restarting the browser is not desirable, in Chrome you can clear the cached content by:

  1. Start react-boilerplate app with npm start
  2. Open localhost:3000 (in Chrome)
  3. Open Chrome dev tools > Resources tab
  4. Delete all cached content under Local Storage, Session Storage, Application Cache, Cache Storage and Service Workers.
  5. Close browser tab and stop server
  6. npm run start:production

A browser restart, or this procedure, needs to be done every time you run a production build in your browser, and is a local workaround only. How much of a problem this is depends on how frequently you update your app, and how critical having the latest content is to your end users.

@ncrawlins
Copy link
Author

It's not a problem in development, because service workers aren't running. It's only a problem when a new version is deployed to production. It is being served from IIS 8.5 running .net core.

Restarting chrome in windows does not fix it, I have to clear all cache or unregister the service workers using chrome://serviceworker-internals/

I have no problems clearing my cache, but right now we are getting active feedback from users that can't be expected to mess with browser settings, as basic as that may seem. They are getting a new version about once a week, sometimes more.

I was hoping there was some way to maybe put a setting in the OfflinePlugin config or somewhere. So that when i pushed a new build it would know to grab the new index.html.

But if that's just the way it's meant to work, then I guess I can just disable the offline stuff for now because they don't really need it, and the app is changing a lot.

@gihrig
Copy link
Contributor

gihrig commented Jul 5, 2016

@mxstbr , anyone else, is there a production-ready solution to updating content in offline-first?

@mxstbr mxstbr added the bug label Jul 7, 2016
@mxstbr
Copy link
Member

mxstbr commented Jul 7, 2016

Oh my, that sounds horrible @ncrawlins! @NekR, any input here?

@NekR
Copy link
Contributor

NekR commented Jul 7, 2016

Okay, first of all, it's not that bad :-) Let me example you how ServiceWorker and AppCache update process works.

Browser fetches ServiceWorker file each time user navigates to your website. If new ServiceWorker is found, it's immediately running along side with current SW. This new SW gets only install event a this time, which allow it to prepare/cache assets of a new version. New SW doesn't start controlling pages until all tabs of your website are closed, this is by design in SW.

AppCache has slightly simpler update mechanism: it also downloads manifest.appcache on each navigation to your site (simplified) and if new AppCache is avaialable, browser installs new AppCache and removes old one. This means that on a next page refresh browser will load files from new AppCache.

I guess AppCache is a confusing root here--you just expect SW to have the same update process. You also mentioned Cmd/Ctrl+R, it doesn't updates or reloads new SW, it tells to browser to bypass currently controlling ServiceWorker. If you have only 1 tab opened, then this flow can update SW:

Refresh (downloads new SW) -> Ctrl/Cmd+Refresh (bypasses SW, now SW doesn't control any pages, new SW can be used) -> Refresh (load new SW)

This is how it works. Of course, there is a way to update SW/AppCache when you want, you are developer after all :-)

// offline-plugin config
// tell to it to generate events for SW

new OfflinePlugin({
  ServiceWorker: {
    events: true
  }
})
// client-side code

const runtime = require('offline-plugin/runtime');

runtime.install({
  onUpdating: () => {
    console.log('SW Event:', 'onUpdating');
  },
  onUpdateReady: () => {
    console.log('SW Event:', 'onUpdateReady');
    // Tells to new SW to take control immediately
    runtime.applyUpdate();
  },
  onUpdated: () => {
    console.log('SW Event:', 'onUpdated');
    // Reload the webpage to reload into new version
    window.location.reload();
  },

  onUpdateFailed: () => {
    console.log('SW Event:', 'onUpdateFailed');
  }
});

There are similar option for AppCache: AppCache: { events: true }, but I don't recommend using it unless you really need it. AppCache's events are buggy and unstable and some times may not fire at all.

Restarting chrome in windows does not fix it, I have to clear all cache or unregister the service workers using chrome://serviceworker-internals/

@ncrawlins are use sure about that, can you re-check one more time? Here is how to test:

  1. Load your webpage
  2. Build and deploy new version with something changed, add alert(1) for example
  3. Reload the webpage
  4. Close the tab of the webpage (make sure there is no more open tabs of this website)
  5. Open that webpage again in a new tab
  6. Let us know if you see alert(1)

Thanks.

@NekR
Copy link
Contributor

NekR commented Jul 7, 2016

Oh, and:

then I guess I can just disable the offline stuff for now because they don't really need it, and the app is changing a lot.

If you don't need it--then simply don't use it. But I should warn you that you cannot simply remove sw.js and AppCache files from your server. If you will do so, your users will have stale content forever (until manual cache clear). To stop using SW/AppCache you have to ship uninstall code.

@jakearchibald
Copy link

Here's a quick video where I run through the update cycle of a SW. https://twitter.com/jaffathecake/status/709011058938269696 - it's basically the same as Chrome's update model.

@mxstbr
Copy link
Member

mxstbr commented Jul 7, 2016

Woah thanks for that @NekR and @jakearchibald – we should add that great explanation to the docs!

@NekR
Copy link
Contributor

NekR commented Jul 7, 2016

@mxstbr Yeah, I think about it too. I'll it to offline-plugin docs. Feel free to add it to react-boilerplate too, if you think this will help :-)

@ncrawlins
Copy link
Author

ncrawlins commented Jul 8, 2016

are use sure about that, can you re-check one more time? Here is how to test:

I must have been misremembering. I can't reproduce that. Seems to be working as you described.

@NekR
Copy link
Contributor

NekR commented Jul 8, 2016

So, is this still a bug then? @ncrawlins have you managed to make offline-plugin to work for you as you want?

@mxstbr maybe we should include SW events by default into boilerplate?

@ncrawlins
Copy link
Author

yep, it is working for me. sorry for the initial misinformation about the behavior, but the explanation of how it all works was very helpful.

@NekR
Copy link
Contributor

NekR commented Jul 8, 2016

No problem, I am glad to help.

If something, here I wrote a doc based explanation here (same content, just reworded a bit): https://github.com/NekR/offline-plugin/blob/master/docs/updates.md

@ajarbol
Copy link

ajarbol commented Nov 29, 2016

For the record I would like to mention that my default Nginx setup had sw.js, loaded from disk. I needed to add the following directive to my nginx.conf file to ensure a correct lifecycle:

location /sw.js {
    add_header Cache-Control "no-cache";
    expires off;
    access_log off;
}

The defaults might be different in an Express or Apache setup, but maybe this could be considered an addition to https://github.com/mxstbr/react-boilerplate/blob/master/app/.nginx.conf @mxstbr
Many thanks for the above clarifications, they were quite enlightening!

@NekR
Copy link
Contributor

NekR commented Nov 29, 2016

Yeah, SW file should be served without cache enabled for it. Otherwise you may get stale SW up to 24h. Though, that's gonna change per spec SW file will always (unless opt-in) without taking cache into account. But that's future :-)

@gihrig
Copy link
Contributor

gihrig commented Dec 24, 2016

I opened PR #1381 to address server cache settings. If others could take a look that would be helpful.

@gihrig gihrig mentioned this issue Jan 2, 2017
mxstbr pushed a commit that referenced this issue Jan 14, 2017
…1381)

* docs(servers): update server conf files for offline-first per #645

re caching see #645 (comment)

Apache
http://stackoverflow.com/a/33287352/522756

Nginx
https://www.nginx.com/blog/nginx-caching-guide/

* Update .gitattributes

added "." to nginx.conf

* Remove empty line in list

* Picked a nit :-)
AnhHT added a commit to AnhHT/react-boilerplate that referenced this issue Jan 18, 2017
* feat(docs): Extracting packages into their own modules (react-boilerplate#979)

* fix(internals): Fix babel relative preset

Fix webpack issue with relative babel preset paths:
babel/babel-loader#149

* feat(docs): Add docs for extracting components

Add draft version of docs describing how to extract components to their own
npm packages.

* feat(core): Move to Jest for testing (react-boilerplate#980)

* Add Jest

collect coverage

* fix(tests): set config and globals

add coverage and script

update coveralls script

update chai to jest syntax

args should return an array

chore(tests): add babel-jest, tweak config

chore(tests): update coverage settings

feat(cov): remove untested closure

chore(core): update watch script, use jest-cli

fix(watch): add no-cache and watchAll flags

* Remove generator test

* jest-cli@16

* chore(jest): Remove rootDir

* rebase against 3.3.0

* fix(commands): Fix 'npm run clean' breaking (react-boilerplate#1185) (react-boilerplate#1186)

Added a constants.js file to templates that contains the DEFAULT_LOCALE
export to be added to containers/App/constants on 'npm run clean'.

* fix(example): Fix i18n button not updating (react-boilerplate#1187)

* feat(docs): Faq: staying updated with boilerplate (react-boilerplate#1192)

* fix(example): Fix console error on lang change (react-boilerplate#1200)

* fix(core): npm run generate language is not properly created. (react-boilerplate#1199)

* rerun extract-intl

* add default language to language provider

* feat(webpack): new query object syntax (react-boilerplate#1198)

* feat(ci): Node v7 support (react-boilerplate#1197)

* Node version support update

* Update CI node versions

* fix(docs): Replace start:prod with independent start:production (react-boilerplate#1204)

* fix(example): Fix default Intl polyfill language (react-boilerplate#1208)

* fix(docs): Fix typo in file name (react-boilerplate#1211)

* fix(example): Use `createStructuredSelector` instead of `createSelector` (react-boilerplate#1212)

* chore(deps): update deps roll-up Nov-12-2016 (react-boilerplate#1225)

* chore(deps): update deps roll-up Nov-19-2016 (react-boilerplate#1252)

* Prevent language duplication (react-boilerplate#1253)

* Satisfy ESLint rule: no-restricted-syntax (react-boilerplate#1243)

* feat(webpack) Add circular dependency plugin for Webpack. (react-boilerplate#1262)

* feat(webpack) Add circular dependency plugin for Webpack.

This plugin detects circular dependencies and shows a warning or fails.
It is less obtrusive to just show a warning. That's why it defaults to
that.

* small fix to webpack config

* Remove webpack DedupePlugin (react-boilerplate#1218)

* Fix typo in container generator (react-boilerplate#1242)

* fix(eslint config): resolve numerous invalid lint errors seen in Atom editor (react-boilerplate#1261)

* Disable ESLint rule: no-confusing-arrow (react-boilerplate#1238)

* Fix links to styled-components doc (react-boilerplate#1289)

* Add missing document (Using Sass section CSS) to table content (react-boilerplate#1271)

* fix react-boilerplate#1270

* add brackets to document Using Sass

* Remove '#if wantCSS' from generator templates (react-boilerplate#1260)

Remove '#if wantCSS' from container generator

Remove '#if wantCSS' from es6 pure generator template

* feat(core): Don't import all of lodash

* fix(package.json): Required npm version (react-boilerplate#1219)

* Fix wrong npm version introduced with d202b07

Commit d202b07 introduced a not existing npm version of >= 5 which does not exist. The correct npm version is checked during installation which might otherwise lead to an error. Conclusion might be that this was meant to be node >= 5 like mentioned in react-boilerplate#1197

* Add the supported version of node

* chore(deps): update deps roll-up Dec-03-2016 (react-boilerplate#1301)

* chore(deps): update deps roll-up Dec-03-2016

* fix(deps): sagas loaded twice - roll back react-router-redux 4.0.7 -> 4.0.6

* chore(test config): expand Jest moduleNameMapper key to include common file types (react-boilerplate#1293)

* chore(selectors): refactor selectors (react-boilerplate#1205)

* Improve .editorconfig, change insert_final_newline to true, add trim_trailing_whitespace (react-boilerplate#1239)

* fix(scripts): make LocaleToggle's massages compatible with `extract-intl` script (react-boilerplate#1251)

Fixes react-boilerplate#1221
Reverts back react-boilerplate#813

* feat(example): Extracted ReposList (react-boilerplate#1285)

* Bfix/reorder imports (react-boilerplate#1275)

* Reorder imports

* Track package.json

* Reorder remaining imports

* Revert few changes in app/app.js

* Add .ico extension to file-loader regex

* Revert favicon, manifest, .htaccess imports

* Revert favicon, manifest, .htaccess imports

* Remove ico from image-webpack loader extensions

* Move offline-plugin import to the top in templates/app.js

* Match templates/app.js with app/app.js

* Remove import/first from package.json

* Reorder webpack alias imports

* Reorder imports in internals/generators

* Remove German from templates/app.js

* fix(templates): use correct name of a selector (react-boilerplate#1321)

* chore(generators): clean up generator templates (react-boilerplate#1304)

Follow up to react-boilerplate#1260

* fix(generator):  react-boilerplate#1231 'generate container' produces unnecessary return (react-boilerplate#1327)

* chore(internal): fix indentation in 'routeWithReducer' (react-boilerplate#1329)

* fix(HomePage): react-boilerplate#1232 Saga effects should be yielded (react-boilerplate#1328)

* fix(generator): 'generate container' produces unnecessary return - better solution (react-boilerplate#1333)

* fix(generator):  react-boilerplate#1231 'generate container' produces unnecessary return

* fix(generator): improved solution to 'generate container' produces unnecessary return react-boilerplate#1327

* feat(ci): allow for linting of the templates (react-boilerplate#1223)

* feat(ci): allow for linting of the templates

*  Add comment at the top describing the purpose of generate-templates-for-linting.js

* Use __dirname instead of process.cwd()

* Update yarn.lock

* Test coverage updates (react-boilerplate#1334)

* Exclude test files from test coverage

* Add coverage threshold

* Update css readme (react-boilerplate#1338)

* fix(generators, templates): add example app functionality into project templates and generators (react-boilerplate#1331)

* fix(generators, templates): add existing example app functionality into project templates and generators

* fix(generators, templates): add existing example app functionality into project templates and generators

* split messages import to avoid disabling an eslint rule

* feat(server): Add host command line parameter to start (react-boilerplate#1249)

* add host parameter to logger

* add host parameter to server

* update docs to include host command line parameter

* update host port command doc based on suggesitons

* Rollback image-webpack-loader (react-boilerplate#1342)

* Remove babel-jest expicit dependency (react-boilerplate#1345)

implements react-boilerplate#1344

* Make  compatible with other babel plugins (react-boilerplate#1355)

* Remove psi and pagespeed (react-boilerplate#1352)

* removing psi, pagespeed, and doc references

* remove psi from yarn.lock

* Trigger full page reload when hmr fails (react-boilerplate#1357)

Fixes react-boilerplate#1353

* refactor(server): remove console.log causing server screen clutter (react-boilerplate#1361)

* feat(example): Add route loading progress bar (react-boilerplate#1008)

* Add ProgressBar, modify App and write tests

* fix eslint warnings

* Prevent memory leak in App/index, Fix animation of ProgressBar, Add more tests

* Add more tests for ProgressBar life cycle methods

* Rename css class names, remove eslint-disable, add comments

* Remove comments from ProgressBar tests

* Prevent re-rendering of ProgressBar

* Fix failing test

* Add one more condition to complete progress

* Update index.test.js

Bring import order in line with react-boilerplate#1275

* Update App/index.js

* Update App/index.js

* Fix re-rendering and make tests pass

* Move progress route hooks out of <App />, update tests

* Reset progress bar speed

* Move <ProgressBar /> out of <App />

* Update tests

* Move withProgressBar to components/ProgressBar

* Rename withProgressBar -> index.js.

* Add docs for ProgressBar working/usage

* Update progress bar.md

* Split ProgressBar/styles.js into two separate files

* chore(package.json): update dependecy

The test/build failed due to a regressed dependency. 

"react-addons-test-utils": "15.3.2", ->  "react-addons-test-utils": "15.4.1",

* feat(docs) a beginner's guide to RBP (react-boilerplate#1366)

* Create introduction.md

* Update introduction.md

Minor edits for grammar and structure.

Overall, really really good. The hours of dedicated effort you put in will be appreciated by many to come! Very well done 😄

* Update introduction.md

Here I have implemented the changes mentioned by @web2style and @lamoglia Thanks guys! :spakles:

* Host workflow.png internally

* Reference local image in markdown

* Rename Workflow.png -> workflow.png

* Move to Jest Documentation (react-boilerplate#1390)

* Move to Jest Documentation

- Move from Mocha to Jest documentation
- Remove rewire docs and replace with Jest snapshot information

* Minor edits

Overall very good, only a few minor edits for style.

* Remove jest-cli cmd

* Update commands.md

* Update deployment.md

* fix(core): ngrok not working (react-boilerplate#1399)

Node's http.Server#listen does some smart choosing for default host '::' or '0.0.0.0' depending on IPv6 support. Use that instead of binding to localhost specifically. This mimics previous server functionality and allows ngrok access to work again.

* chore(deps): updated redux-saga version (react-boilerplate#1388)

* Update Changelog.md

* Update package.json

* 3.4.0

* 3.4.0

* 3.4.0

* docs(toc): include link to new intor document (react-boilerplate#1401)

* Update Changelog

* chore(deps): update webpack (react-boilerplate#1358)

* chore(deps): update webpack

* Update 'Introduction'

* Cache again

* Fix warning during generation of webpack dll file

* Describe how to turn off the warnings in production

* Bump webpack

* Improve the docs

* Reorg some templates and add tests (react-boilerplate#1414)

* Reorg some templates and add tests

- Also make sure that we keep LanguageProvider tests after clean

* Move to container structure for internals

* Remove old filename ref

* Actually remove folders, thanks @Dattaya

* Fix react-boilerplate#1300 broken link (react-boilerplate#1429)

* Fix react-boilerplate#1435 comment (react-boilerplate#1437)

* Add AWS documentation to deployment.md (react-boilerplate#1442)

* Add AWS documentation to deployment.md

* Minor changes

* feature(nginx): integrating mozillas nginx secure tls configuration i… (react-boilerplate#1393)

* feature(nginx): integrating mozillas nginx secure tls configuration into .nginx.conf

* feature(nginx): updating server-config docs for apache and nginx to reflect security configurations

* Update .nginx.conf

Add Link for DHE Handshake and minor edits for style/grammar

* Update server-configs.md

Minor edits for style/grammar

* RFC: chore(ci): switch to yarn (react-boilerplate#1415)

* chore(ci): switch to yarn

* Remove 'yarn version' because: 'Can't answer a question unless a user TTY'

* chore(deps): remove chai and chai-enzyme (react-boilerplate#1441)

* react-boilerplate#1406 remove lint:css documentation references (react-boilerplate#1445)

* Removed redundant lint:css

Remove lint:css references

* Removed redundant lint:js reference

* docs(ISSUE_TEMPLATE): add request for RBP version (react-boilerplate#1425)

As there are often several version in various state of completion and we attempt to release often. It's vital to know what version of RBP is involved in issues.

* chore(internals): do not check file sizes of main chunk and favicon (react-boilerplate#1424)

* chore(internals): do not check file sizes of main chunk and favicon

* Reword explanation in the docs

* Move test (react-boilerplate#1432)

* feature(test): enable build without test

Git pre-commit hook still prevents submit failing code

* docs(test): updated documentation

Clarified test, build and start:production

* test(selector test generator): change 'test case' to 'true'

This make it easier 'cheat' on the test (double-click to select). Useful when manually testing generator output.

* docs(test): updated documentation

Clarified start:production

* remove erroneous single quote

* test(travis): revert yarn calls to npm

Travis does not directly support yarn

As described at https://blog.travis-ci.com/2016-11-21-travis-ci-now-supports-yarn
Travis looks for yarn.lock and maps npm calls to yarn, if present.

* config(travis.yaml): move test and build to script section (react-boilerplate#1455)

* chore(docs): cleanup of introduction

* chore(docs): cleanup of introduction

* chore(readme): add hitchhikers guide to the readme

* Several minor edits...

* Remove (in no particular order)

* docs(servers): update server conf files for offline-first per react-boilerplate#645 (react-boilerplate#1381)

* docs(servers): update server conf files for offline-first per react-boilerplate#645

re caching see react-boilerplate#645 (comment)

Apache
http://stackoverflow.com/a/33287352/522756

Nginx
https://www.nginx.com/blog/nginx-caching-guide/

* Update .gitattributes

added "." to nginx.conf

* Remove empty line in list

* Picked a nit :-)

* chore(core): Move mocks/ folder to internals/ (react-boilerplate#1460)

* Update CHANGELOG
AnhHT added a commit to AnhHT/react-boilerplate that referenced this issue Jan 20, 2017
* feat(docs): Extracting packages into their own modules (react-boilerplate#979)

* fix(internals): Fix babel relative preset

Fix webpack issue with relative babel preset paths:
babel/babel-loader#149

* feat(docs): Add docs for extracting components

Add draft version of docs describing how to extract components to their own
npm packages.

* feat(core): Move to Jest for testing (react-boilerplate#980)

* Add Jest

collect coverage

* fix(tests): set config and globals

add coverage and script

update coveralls script

update chai to jest syntax

args should return an array

chore(tests): add babel-jest, tweak config

chore(tests): update coverage settings

feat(cov): remove untested closure

chore(core): update watch script, use jest-cli

fix(watch): add no-cache and watchAll flags

* Remove generator test

* jest-cli@16

* chore(jest): Remove rootDir

* rebase against 3.3.0

* fix(commands): Fix 'npm run clean' breaking (react-boilerplate#1185) (react-boilerplate#1186)

Added a constants.js file to templates that contains the DEFAULT_LOCALE
export to be added to containers/App/constants on 'npm run clean'.

* fix(example): Fix i18n button not updating (react-boilerplate#1187)

* feat(docs): Faq: staying updated with boilerplate (react-boilerplate#1192)

* fix(example): Fix console error on lang change (react-boilerplate#1200)

* fix(core): npm run generate language is not properly created. (react-boilerplate#1199)

* rerun extract-intl

* add default language to language provider

* feat(webpack): new query object syntax (react-boilerplate#1198)

* feat(ci): Node v7 support (react-boilerplate#1197)

* Node version support update

* Update CI node versions

* fix(docs): Replace start:prod with independent start:production (react-boilerplate#1204)

* fix(example): Fix default Intl polyfill language (react-boilerplate#1208)

* fix(docs): Fix typo in file name (react-boilerplate#1211)

* fix(example): Use `createStructuredSelector` instead of `createSelector` (react-boilerplate#1212)

* chore(deps): update deps roll-up Nov-12-2016 (react-boilerplate#1225)

* chore(deps): update deps roll-up Nov-19-2016 (react-boilerplate#1252)

* Prevent language duplication (react-boilerplate#1253)

* Satisfy ESLint rule: no-restricted-syntax (react-boilerplate#1243)

* feat(webpack) Add circular dependency plugin for Webpack. (react-boilerplate#1262)

* feat(webpack) Add circular dependency plugin for Webpack.

This plugin detects circular dependencies and shows a warning or fails.
It is less obtrusive to just show a warning. That's why it defaults to
that.

* small fix to webpack config

* Remove webpack DedupePlugin (react-boilerplate#1218)

* Fix typo in container generator (react-boilerplate#1242)

* fix(eslint config): resolve numerous invalid lint errors seen in Atom editor (react-boilerplate#1261)

* Disable ESLint rule: no-confusing-arrow (react-boilerplate#1238)

* Fix links to styled-components doc (react-boilerplate#1289)

* Add missing document (Using Sass section CSS) to table content (react-boilerplate#1271)

* fix react-boilerplate#1270

* add brackets to document Using Sass

* Remove '#if wantCSS' from generator templates (react-boilerplate#1260)

Remove '#if wantCSS' from container generator

Remove '#if wantCSS' from es6 pure generator template

* feat(core): Don't import all of lodash

* fix(package.json): Required npm version (react-boilerplate#1219)

* Fix wrong npm version introduced with d202b07

Commit d202b07 introduced a not existing npm version of >= 5 which does not exist. The correct npm version is checked during installation which might otherwise lead to an error. Conclusion might be that this was meant to be node >= 5 like mentioned in react-boilerplate#1197

* Add the supported version of node

* chore(deps): update deps roll-up Dec-03-2016 (react-boilerplate#1301)

* chore(deps): update deps roll-up Dec-03-2016

* fix(deps): sagas loaded twice - roll back react-router-redux 4.0.7 -> 4.0.6

* chore(test config): expand Jest moduleNameMapper key to include common file types (react-boilerplate#1293)

* chore(selectors): refactor selectors (react-boilerplate#1205)

* Improve .editorconfig, change insert_final_newline to true, add trim_trailing_whitespace (react-boilerplate#1239)

* fix(scripts): make LocaleToggle's massages compatible with `extract-intl` script (react-boilerplate#1251)

Fixes react-boilerplate#1221
Reverts back react-boilerplate#813

* feat(example): Extracted ReposList (react-boilerplate#1285)

* Bfix/reorder imports (react-boilerplate#1275)

* Reorder imports

* Track package.json

* Reorder remaining imports

* Revert few changes in app/app.js

* Add .ico extension to file-loader regex

* Revert favicon, manifest, .htaccess imports

* Revert favicon, manifest, .htaccess imports

* Remove ico from image-webpack loader extensions

* Move offline-plugin import to the top in templates/app.js

* Match templates/app.js with app/app.js

* Remove import/first from package.json

* Reorder webpack alias imports

* Reorder imports in internals/generators

* Remove German from templates/app.js

* fix(templates): use correct name of a selector (react-boilerplate#1321)

* chore(generators): clean up generator templates (react-boilerplate#1304)

Follow up to react-boilerplate#1260

* fix(generator):  react-boilerplate#1231 'generate container' produces unnecessary return (react-boilerplate#1327)

* chore(internal): fix indentation in 'routeWithReducer' (react-boilerplate#1329)

* fix(HomePage): react-boilerplate#1232 Saga effects should be yielded (react-boilerplate#1328)

* fix(generator): 'generate container' produces unnecessary return - better solution (react-boilerplate#1333)

* fix(generator):  react-boilerplate#1231 'generate container' produces unnecessary return

* fix(generator): improved solution to 'generate container' produces unnecessary return react-boilerplate#1327

* feat(ci): allow for linting of the templates (react-boilerplate#1223)

* feat(ci): allow for linting of the templates

*  Add comment at the top describing the purpose of generate-templates-for-linting.js

* Use __dirname instead of process.cwd()

* Update yarn.lock

* Test coverage updates (react-boilerplate#1334)

* Exclude test files from test coverage

* Add coverage threshold

* Update css readme (react-boilerplate#1338)

* fix(generators, templates): add example app functionality into project templates and generators (react-boilerplate#1331)

* fix(generators, templates): add existing example app functionality into project templates and generators

* fix(generators, templates): add existing example app functionality into project templates and generators

* split messages import to avoid disabling an eslint rule

* feat(server): Add host command line parameter to start (react-boilerplate#1249)

* add host parameter to logger

* add host parameter to server

* update docs to include host command line parameter

* update host port command doc based on suggesitons

* Rollback image-webpack-loader (react-boilerplate#1342)

* Remove babel-jest expicit dependency (react-boilerplate#1345)

implements react-boilerplate#1344

* Make  compatible with other babel plugins (react-boilerplate#1355)

* Remove psi and pagespeed (react-boilerplate#1352)

* removing psi, pagespeed, and doc references

* remove psi from yarn.lock

* Trigger full page reload when hmr fails (react-boilerplate#1357)

Fixes react-boilerplate#1353

* refactor(server): remove console.log causing server screen clutter (react-boilerplate#1361)

* feat(example): Add route loading progress bar (react-boilerplate#1008)

* Add ProgressBar, modify App and write tests

* fix eslint warnings

* Prevent memory leak in App/index, Fix animation of ProgressBar, Add more tests

* Add more tests for ProgressBar life cycle methods

* Rename css class names, remove eslint-disable, add comments

* Remove comments from ProgressBar tests

* Prevent re-rendering of ProgressBar

* Fix failing test

* Add one more condition to complete progress

* Update index.test.js

Bring import order in line with react-boilerplate#1275

* Update App/index.js

* Update App/index.js

* Fix re-rendering and make tests pass

* Move progress route hooks out of <App />, update tests

* Reset progress bar speed

* Move <ProgressBar /> out of <App />

* Update tests

* Move withProgressBar to components/ProgressBar

* Rename withProgressBar -> index.js.

* Add docs for ProgressBar working/usage

* Update progress bar.md

* Split ProgressBar/styles.js into two separate files

* chore(package.json): update dependecy

The test/build failed due to a regressed dependency. 

"react-addons-test-utils": "15.3.2", ->  "react-addons-test-utils": "15.4.1",

* feat(docs) a beginner's guide to RBP (react-boilerplate#1366)

* Create introduction.md

* Update introduction.md

Minor edits for grammar and structure.

Overall, really really good. The hours of dedicated effort you put in will be appreciated by many to come! Very well done 😄

* Update introduction.md

Here I have implemented the changes mentioned by @web2style and @lamoglia Thanks guys! :spakles:

* Host workflow.png internally

* Reference local image in markdown

* Rename Workflow.png -> workflow.png

* Move to Jest Documentation (react-boilerplate#1390)

* Move to Jest Documentation

- Move from Mocha to Jest documentation
- Remove rewire docs and replace with Jest snapshot information

* Minor edits

Overall very good, only a few minor edits for style.

* Remove jest-cli cmd

* Update commands.md

* Update deployment.md

* fix(core): ngrok not working (react-boilerplate#1399)

Node's http.Server#listen does some smart choosing for default host '::' or '0.0.0.0' depending on IPv6 support. Use that instead of binding to localhost specifically. This mimics previous server functionality and allows ngrok access to work again.

* chore(deps): updated redux-saga version (react-boilerplate#1388)

* Update Changelog.md

* Update package.json

* 3.4.0

* 3.4.0

* 3.4.0

* docs(toc): include link to new intor document (react-boilerplate#1401)

* Update Changelog

* chore(deps): update webpack (react-boilerplate#1358)

* chore(deps): update webpack

* Update 'Introduction'

* Cache again

* Fix warning during generation of webpack dll file

* Describe how to turn off the warnings in production

* Bump webpack

* Improve the docs

* Reorg some templates and add tests (react-boilerplate#1414)

* Reorg some templates and add tests

- Also make sure that we keep LanguageProvider tests after clean

* Move to container structure for internals

* Remove old filename ref

* Actually remove folders, thanks @Dattaya

* Fix react-boilerplate#1300 broken link (react-boilerplate#1429)

* Fix react-boilerplate#1435 comment (react-boilerplate#1437)

* Add AWS documentation to deployment.md (react-boilerplate#1442)

* Add AWS documentation to deployment.md

* Minor changes

* feature(nginx): integrating mozillas nginx secure tls configuration i… (react-boilerplate#1393)

* feature(nginx): integrating mozillas nginx secure tls configuration into .nginx.conf

* feature(nginx): updating server-config docs for apache and nginx to reflect security configurations

* Update .nginx.conf

Add Link for DHE Handshake and minor edits for style/grammar

* Update server-configs.md

Minor edits for style/grammar

* RFC: chore(ci): switch to yarn (react-boilerplate#1415)

* chore(ci): switch to yarn

* Remove 'yarn version' because: 'Can't answer a question unless a user TTY'

* chore(deps): remove chai and chai-enzyme (react-boilerplate#1441)

* react-boilerplate#1406 remove lint:css documentation references (react-boilerplate#1445)

* Removed redundant lint:css

Remove lint:css references

* Removed redundant lint:js reference

* docs(ISSUE_TEMPLATE): add request for RBP version (react-boilerplate#1425)

As there are often several version in various state of completion and we attempt to release often. It's vital to know what version of RBP is involved in issues.

* chore(internals): do not check file sizes of main chunk and favicon (react-boilerplate#1424)

* chore(internals): do not check file sizes of main chunk and favicon

* Reword explanation in the docs

* Move test (react-boilerplate#1432)

* feature(test): enable build without test

Git pre-commit hook still prevents submit failing code

* docs(test): updated documentation

Clarified test, build and start:production

* test(selector test generator): change 'test case' to 'true'

This make it easier 'cheat' on the test (double-click to select). Useful when manually testing generator output.

* docs(test): updated documentation

Clarified start:production

* remove erroneous single quote

* test(travis): revert yarn calls to npm

Travis does not directly support yarn

As described at https://blog.travis-ci.com/2016-11-21-travis-ci-now-supports-yarn
Travis looks for yarn.lock and maps npm calls to yarn, if present.

* config(travis.yaml): move test and build to script section (react-boilerplate#1455)

* chore(docs): cleanup of introduction

* chore(docs): cleanup of introduction

* chore(readme): add hitchhikers guide to the readme

* Several minor edits...

* Remove (in no particular order)

* docs(servers): update server conf files for offline-first per react-boilerplate#645 (react-boilerplate#1381)

* docs(servers): update server conf files for offline-first per react-boilerplate#645

re caching see react-boilerplate#645 (comment)

Apache
http://stackoverflow.com/a/33287352/522756

Nginx
https://www.nginx.com/blog/nginx-caching-guide/

* Update .gitattributes

added "." to nginx.conf

* Remove empty line in list

* Picked a nit :-)

* chore(core): Move mocks/ folder to internals/ (react-boilerplate#1460)

* Update CHANGELOG
@akarve
Copy link
Contributor

akarve commented Jul 27, 2017

To add my experience, I still consider "obstinate service worker" a problem. We are going to be removing service worker from our production code. Even after implementing the above-recommended onUpdate hooks, we find that SW is immune in many cases to all but hard reload (e.g. Shift+Reload on Chrome). It seems that SW refuses to budge if there are any active tabs that hold the site even in the tab history. We have seen multiple cases of SW refusing to update-in-place even after restarting the browser. This won't work for our production website as we can't afford to show stale content to our users--and it happens often with SW.

Programmatic uninstall not really viable given that SW will block new JS from executing.

@NekR
Copy link
Contributor

NekR commented Jul 27, 2017

Never seen that issue, but thanks for the update.

@SamMatthewsIsACommonName
Copy link

SamMatthewsIsACommonName commented Aug 13, 2017

I also have this issue with a website that was initially made using this boilerplate, and has since moved to a next.js app as we needed server side rendering. Trouble is even months later I'm still getting an old version of the site from the service worker, and I need to hard refresh to get the actual version. This makes analysing the live site basically imposssible. Is there a way to get rid of this? If I re install chrome would that change anything? Cheers

screen shot 2017-08-13 at 22 30 48

EDIT: my bad, in my case I can just remove it from the 'application' tab of developer console, but if we had have had customers at that time might have been a problem hehe

@NekR
Copy link
Contributor

NekR commented Aug 13, 2017

Well, a previous person by some reason said that "programmatic uninstall" isn't viable by some mysterious reason. That isn't true of course. Just unregister ServiceWorker from your script and unregistration is done reload the page.

@akarve
Copy link
Contributor

akarve commented Aug 13, 2017

@NekR Are you are referring to this method of unregistering the service worker that I linked above? The problem with said method is, if an existing registered service worker is running, any new code remains in the waiting state and doesn't get a chance to call unregister (exceptions are Shift+Reload, whose effects often revert on reload, and browser restart, which is also unreliable). Service Worker on the latest Chrome even caches index.html. Where do you propose that we insert the unregister() call given that Service Worker will front run almost every resource request? We have seen users pull up months old web content due to this issue.

I have also tried the methods outlined above to no avail.

@michelalbers
Copy link

michelalbers commented Aug 20, 2017

Same here ... it's just impossible to do timed rollouts of features. Customers complaining about stuff not being visible. How can I reliably get rid of service workers?

EDIT

I ended up by removing the OfflinePlugin and serving a noop sw.js:

sw.js

    // A simple, no-op service worker that takes immediate control.
    
    self.addEventListener('install', () => {
      // Skip over the "waiting" lifecycle state, to ensure that our
      // new service worker is activated immediately, even if there's
      // another tab open controlled by our older service worker code.
      self.skipWaiting();
    });
    
    /*
    self.addEventListener('activate', () => {
      // Optional: Get a list of all the current open windows/tabs under
      // our service worker's control, and force them to reload.
      // This can "unbreak" any open windows/tabs as soon as the new
      // service worker activates, rather than users having to manually reload.
      self.clients.matchAll({type: 'window'}).then(windowClients => {
        windowClients.forEach(windowClient => {
          windowClient.navigate(windowClient.url);
        });
      });
    });
    */

I put that file into a directory called static and added it to the build by adding WebpackCopy to my webpack.babel.js:

webpack.base.babel.js

    ...
    new CopyWebpackPlugin([{
        from: 'static',
    }]),
    ...

I then added the following code to app.js:

app.js

    if (navigator.serviceWorker) {
      navigator.serviceWorker.getRegistrations().then((registrations) => {
        for (const registration of registrations) {
            registration.unregister();
        }
      });
    }

I hope that someday all customers will have the new dummy sw.js and I can finally roll out timed deployments. I think Offline capabilities are a nice idea but not practical for most apps. Maybe we should update the docs here to avoid confusing people.

@NekR
Copy link
Contributor

NekR commented Aug 20, 2017

@akarve just update your ServiceWorker code if it's old. Delete caches if you don't want them. Update them if you still need them. You can even put ServiceWorker unregistration code into ServiceWorker if you think that would be better for you.

@dimaryaz
Copy link

@michelalbers: I tried your suggestion; very useful! The "navigate" call didn't seem to reload the existing pages, though - I suspect it got intercepted by the old service worker.

I added a "claim" call, and that seems to work for me. Here's my sw.js:

self.addEventListener('install', () => {
  self.skipWaiting();
});
self.addEventListener('activate', () => {
  self.clients.claim().then(() => {
    self.clients.matchAll({ type: 'window' }).then((windowClients) => {
      windowClients.forEach((windowClient) => {
        windowClient.navigate(windowClient.url);
      });
    });
  });
});

@michelalbers
Copy link

@dimaryaz nice! Guess this is settled then ;)

marvellous122 added a commit to marvellous122/react-redux-base that referenced this issue Jan 19, 2018
…1381)

* docs(servers): update server conf files for offline-first per #645

re caching see react-boilerplate/react-boilerplate#645 (comment)

Apache
http://stackoverflow.com/a/33287352/522756

Nginx
https://www.nginx.com/blog/nginx-caching-guide/

* Update .gitattributes

added "." to nginx.conf

* Remove empty line in list

* Picked a nit :-)
@lock
Copy link

lock bot commented May 29, 2018

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators May 29, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

10 participants