TNRIS / dataHub

ReactJS frontend web application for browsing, downloading, and inquiring about TNRIS public data and historical imagery.
https://data.tnris.org
7 stars 0 forks source link

Cache Reworking #297

Open adambreznicky opened 3 years ago

adambreznicky commented 3 years ago

after the recent create-react-app package update and it's dropping use of 'precache' files, it has become more significant that datahub's cache management should probably be reworked. in terms of onload, @ctrepka wrote in the deletion of browser precache and @adambreznicky wrote in stashing/monitoring of the app version within local storage. these steps work but only to the extent that the user hard resets (CTRL+F5) their browser to pull these updates. the proposed reworking should maneuver around any necessity for our users to have to hard reset and clear their cache within their client side browser. should cache-control meta tags within html be used to prevent any client side caching ever? how would this effect performance? are there other methods to prevent client side caching? if possible, what generic code can be written (along the lines of version management in local storage) to signal a refresh?

a team meeting to brainstorm and analysis of our options would help kick off this enhancement

precache removal on load 6eccfa253d31261afa593b3d5b6563ef63e0961e local storage app version c980906aed70d5dc8bcbcc2e190651daef3ed7ac

JasonKleinert commented 3 years ago

Here are some relevant resource links with ideas related to caching with PWAs:

ctrepka commented 3 years ago

Still reading the articles you linked @JasonKleinert, but here are a few updates specifically about react-scripts v4.0^ and its adoption of the workbox api for creating PWAs. Wondering if this might just be a matter of updating the service-worker files in the repo?

JasonKleinert commented 3 years ago

@ctrepka we could disable the service worker in our src/index.js file? When I initially built the React app I left the service worker in there because it came as part of the standard set up. There isn't a specific need for this app to be a PWA. The new support for the workbox api could make using a service worker more straightforward in the future if that is what we want to pursue. Should we try disabling the service worker and the code added to manage clearing the cache to see if this solves the issue of the app loading from cache and not recognizing when new updates are deployed?

ctrepka commented 3 years ago

@ctrepka we could disable the service worker in our src/index.js file?

I think this might work, and is probably worth a shot. I tried yesterday in local production mode (npm run build and served with webpack). It's still not clear to me if it worked or not, honestly, and I think we will need to find someone with a cached version to test in prod.