How to only include (or !exclude) specific paths from caching?

Created on 2 March 2023, about 2 years ago
Updated 13 September 2023, over 1 year ago

Problem/Motivation

Background: The PWA-part of our website is placed behind /app/* URL.

All other website contents should NOT be PWA-enabled.

So in Drupal 7 we were able to use the following in "URLs to exclude":
!app/.*
Now in Drupal 8 the field description is:

Takes a regex, these URLs will use network-only, default config should be, admin/.* and user/reset/.*.

and I'm not sure if this is still working?

If yes, would it perhaps make sense to add the example to the field description?
If not, we should bring it back.

Can someone tell, if this still works? Based on the feedback I can then provide a MR to add the description or re-implement the feature.

Thanks!

Steps to reproduce

Proposed resolution

Instead of using regex, we should instead require the https://github.com/sindresorhus/globby js library and use that to include / exclude paths with a ".gitignore" like syntax.

Remaining tasks

User interface changes

API changes

Data model changes

💬 Support request
Status

Active

Version

2.0

Component

Code

Created by

🇩🇪Germany Anybody Porta Westfalica

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @Anybody
  • 🇩🇪Germany Anybody Porta Westfalica

    Another question would be, if this feature breaks with multilanguage URLs (/en/admin/.*)?
    And it's a bit dangerous that typically Drupal doesn't use regex for such paths and starts paths with a "/". Perhaps we should point this out more verbose, if it can't be changed technically?

  • 🇩🇪Germany Anybody Porta Westfalica

    Besides this exclusion, what's especially needed in my case, seems "scope" = /app, am I right?

    This doesn't make the other points and questions here less important, but makes the scope configuration and working functionality essential in my case.

  • 🇩🇪Germany Anybody Porta Westfalica
  • 🇩🇪Germany Anybody Porta Westfalica

    Perhaps I got things wrong here. Let's discuss and finish this @Grevil.

  • Assigned to Grevil
  • 🇩🇪Germany Grevil

    I think you are misunderstanding this field.

    "urls_to_exclude" has NOTHING to do with the manifest.json. This is a service worker setting and defines the urls to exclude from caching.

    But your point is clear, this should definitely still work for multilingual sites AND for sites having their pwa in a different directory.

  • 🇩🇪Germany Grevil

    Since we are currently using regex to validate whether a URL should be cached or not, there isn't a straight forward way to include (aka !exclude) paths in "urls_to_exclude".

    I think instead of using regex here, we should instead require the https://github.com/sindresorhus/globby js library and use that to include / exclude paths with a ".gitignore" like syntax.

  • Issue was unassigned.
Production build 0.71.5 2024