GithubHelp home page GithubHelp logo

Comments (7)

sebastianbenz avatar sebastianbenz commented on August 17, 2024

//cc @patrickkettner

from amp-sw.

patrickkettner avatar patrickkettner commented on August 17, 2024

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.

kristoferbaxter avatar kristoferbaxter commented on August 17, 2024

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.

kristoferbaxter avatar kristoferbaxter commented on August 17, 2024

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.

gilbertococchi avatar gilbertococchi commented on August 17, 2024

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.

jeffposnick avatar jeffposnick commented on August 17, 2024

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 the NetworkFirst strategy or during revalidation in StaleWhileRevalidate. 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.

kristoferbaxter avatar kristoferbaxter commented on August 17, 2024

On these points:

  • Right now amp-sw is extended from v3 of workbox.
  • 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.