angular/universal

Client side CRUD Operation, HttpCache stays enabled

theo97490 opened this issue ยท 2 comments

๐Ÿž Bug report

What modules are related to this issue?

  • common ( TransferHttpCacheInterceptor )

Description

// Extract from TransferHttpCacheInterceptor 
if (!this.isCacheActive || !['GET', 'HEAD'].includes(req.method)) {
      // Cache is no longer active. Pass the request through.
      return next.handle(req);
    }

Imagine you are doing crud operation on your database (client side). The TransferHttpCacheInterceptor will stay enabled with the behaviour above when you use POST, PATCH, DELETE ... request.

As a result if you navigate on other pages the changes will not be reflected and you likely need to reload the page to see the changes

What i expect is that the cache should be disabled when such methods are used on the client side OR let people customize when to disable the cache by providing a way to disable it.

If i provide withNoHttpTransferCache to provideClientHydration, the cache is not used and everything works as expected.

๐Ÿ”ฌ Minimal Reproduction

Setup a quick page that display a collection from a database ( for the example: A job collection ) using route resolvers.
Setup a REST API route for handling a crud request ( PATCH route for editing a job )
Setup a view to edit one or more items using the HttpClient and the crud request url.

Load the collection page inside your browser, the http cache will contain the collection and the page should be rendered server side.
Navigate to the edition page and edit one or more items.
Navigate to the first page and see that no changes is reflected unless you reload the web app.

Might add actual reproduction code later if asked.

๐ŸŒ Your Environment

@angular-devkit/architect 0.1303.11
@angular-devkit/build-angular 16.0.3
@angular-devkit/core 13.3.11
@angular-devkit/schematics 16.0.3
@angular/cdk 16.0.2
@angular/material 16.0.2
@nguniversal/builders 16.0.2
@nguniversal/express-engine 16.0.2
@schematics/angular 16.0.3
rxjs 7.5.7
typescript 4.9.5

No actually the problem is that my app never stabilize so the cache is never disabled, i don't know why.

There are no reccuring task involved in my app.. . Trying to figure out

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.