Caching responses
The response caching code introduced earlier in this chapter can be applied to almost all HTTP requests, but we only used it for HTTP GET. Of the many different types of HTTP requests, only three are deemed to be cacheable (GET, HEAD, and POST), and the HEAD request doesn't return a body and so isn't useful in our application. The POST method is indicative of an action being performed, so in our context (and most others), it's more important to know that it completed, rather than to save the response it caused (see the Queuing actions section next). To learn more about the types of HTTP requests, see https://en.wikipedia.org/wiki/Hypertext_Transfer_Protocol.
In addition to this, it may not be suitable to cache the response ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access