GoogleChrome / GoogleChrome/workbox

`expireEntries()` does not remove cache entries

Open
#3,411 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
13k
Forks
880
Avg merge
2h 44m
Merged PRs (30d)
8

Description

Hi there! Thanks for the great library!

This was working before, with no change in version of `workbox` packages, so I'm wondering whether this is a change in Google Chrome or its underlying dependencies?

Currently I have some code that clears out a cache when a `POST` request is successful. It's been working fine until recently, but now when testing it appears to not clear the cache.

This is an excerpt of my code:

```
...
const searchExpiration = new CacheExpiration("tags-search", {
maxAgeSeconds: 60
});

registerRoute(
({ url, sameOrigin }) => {
return sameOrigin && url.pathname.includes("/api/v1/tags");
},
new NetworkOnly({
plugins: [
{
fetchDidSucceed: async ({ response }) => {
/**
* When we create a new tag, the data in the backend changes and we need
* to invalidate the local cache for the search queries.
*/

console.log('expiring entries for search')

searchExpiration.expireEntries();

...
redacted
...

return response;
}
}
]
}),
"POST"
);
...
```

I do see `expiring entries for search` in the console, so the route handler is happy, but the caches are still present in the `"tags-search"` cache after calling `expireEntries()`.

Google Chrome version: `Version 135.0.7049.115 (Official Build) (arm64)`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.