Comments (7)
//cc @patrickkettner
from amp-sw.
hi @gilbertococchi!
@sebastianbenz - Happy to change this on amp.dev - are you wanting to change the default behavior for amp-sw? or document why such an option should be used? would be a pretty large breaking change, but certainly doable
from amp-sw.
Changing the default would mean revisiting the decisions here: https://github.com/ampproject/amp-sw/tree/master/src/modules/document-caching
Considering the low usage of the module, this could be done with a major revision bump.
Would @sebastianbenz or @patrickkettner want to test this on AMP.dev?
from amp-sw.
Followed up in-person (over VC) and we decided to first test using a CacheFirst strategy using an override on amp.dev
before changing the default.
from amp-sw.
Would it be possible to remove default AMP HTML document caching first and respect the HTTP Caching default behaviour?
I believe that would be the safest option and then developer can intentionally handle HTML documents via their preferred Caching strategy with an ad hoc regex rule as it's possible with WorkboxJS
from amp-sw.
Just chiming in here from a service worker perspective:
-
The
CacheFirst
strategy in Workbox will not update the cache "in the background" if there is a cache hit. In order words, once an HTML document is cached locally, it's effectively cached for good. I'm assuming it's not what you want for a URL that isn't uniquely revisioned. Instead,StaleWhileRevalidate
would give you "use the cache if possible, but also update the cache in the background" behavior, which would be much safer to use. You might also want to explore some of the options for writing custom strategies in Workbox v6 described in this article. -
Workbox does honor standard
Cache-Control
headers when it goes to the network, either in theNetworkFirst
strategy or during revalidation inStaleWhileRevalidate
. So if those headers are being set, you should already see them take effect. -
Whenever you're using a service worker and potentially require a network call in order to fulfill navigation requests, using navigation preload is a best practice from a performance perspective. (Unfortunately, it's only supported in Chrome.) If you're not already using it,
workbox-navigation-preload
makes it pretty easy to opt-in to using it. -
Happy to follow up with any clarifications as needed!
from amp-sw.
On these points:
- Right now
amp-sw
is extended from v3 ofworkbox
. - It utilizes navigation preload.
- By default uses an extended version
NetworkFirst
for navigation requests to AMP documents.
We haven't upgraded to later versions of workbox
due to people's availability.
from amp-sw.
Related Issues (20)
- Increase cache duration for unversioned files to 7 days HOT 1
- Evaluating link-prefetch module vs Quicklink HOT 9
- Allow user to optin Non amp document to be cached by AMP service worker HOT 4
- Please make the usage end-to-end HOT 3
- Test for `offline-page` is flaky HOT 1
- Move `builder` folder out of `src`
- _offlineFallbackUrl should be private
- denylists should be private
- Convert denylist initialization to constant
- Convert hardcoded LRU Cache limit to configurable
- Move from webpack to Rollup
- Move from yarn to npm
- AmpDocumentNetworkFirst.makeRequest return is not nullable but method body implies that it might be nullable
- DOMException: Failed to execute 'transaction' on 'IDBDatabase': The database connection is closing. HOT 1
- Offline page not working HOT 2
- Error: a redirected response was used for a request whose redirect mode is not "follow"
- Safari: expired certificate resulted in a SW error
- Hey
- Rename the default branch of this repo from `master` to `main` HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from amp-sw.