1

I'm trying to understand some code here:

transfer_http.ts

I'm trying to understand how it invalidates the cache:

// Stop using the cache if there is a mutating call.
    if (req.method !== 'GET' && req.method !== 'HEAD') {
      this.isCacheActive = false;
      this.invalidateCacheEntry(req.url);
    }

How do you get a situation when req.method !== 'GET'? I only use GET requests.

Rusty Rob
  • 16,489
  • 8
  • 100
  • 116
  • Well, if you're following REST, a POST request is used to create data, PUT/PATCH update, DELETE deletes and so on. – Brandon Taylor Mar 18 '19 at 01:42
  • doesn't seem like the best way of knowing when to refresh something. hm – Rusty Rob Mar 18 '19 at 02:28
  • Yeah, I'm not sure why switching request methods would suddenly be a reason to clear the internal cache. – Brandon Taylor Mar 18 '19 at 13:28
  • I guess that as long as you do GET requests on `/documents/56`, the cached version can be used. But if you modify that document, using a POST request, then you would not want to use the cache after that – David Mar 21 '19 at 14:28

0 Answers0