Câu hỏi phỏng vấn API Design
Câu hỏi

Explain Cache-...

Câu trả lời

The Cache-Control header is a fundamental HTTP header used to specify caching policies for both client requests and server responses. It plays a crucial role in controlling how, where, and for how long a resource is cached. Here is a detailed explanation of the Cache-Control header:

Overview

The Cache-Control header is a general header that specifies directives for caching mechanisms in both requests and responses. It provides fine-grained control over how resources are cached, ensuring efficient use of bandwidth, reduced latency, and decreased load on servers.

Syntax

The syntax for the Cache-Control header is as follows:

Copy
Cache-Control: <directive>[, <directive>]*

Directives

The Cache-Control header supports several directives, each serving a specific purpose:

  1. public: Indicates that the response can be cached by any cache, even if it is normally non-cacheable.
  2. private: Specifies that the response is intended for a single user and should not be stored by shared caches (e.g., CDNs).
  3. no-cache: The response can be stored by any cache, but it must be revalidated with the origin server before being used.
  4. no-store: The response must not be stored in any cache.
  5. max-age=: Specifies the maximum amount of time a resource is considered fresh. After this period, the cache must revalidate the resource with the origin server.
  6. s-maxage=: Similar to max-age, but specifically for shared caches. It overrides max-age and the Expires header when present.
  7. max-stale[=]: Indicates that the client is willing to accept a stale response. The optional time specifies the maximum staleness.
  8. min-fresh=: Indicates that the client wants a response that will remain fresh for at least the specified number of seconds.
  9. stale-while-revalidate=: Allows the client to use a stale response while asynchronously checking for a fresh one.
  10. stale-if-error=: Allows the client to use a stale response if the check for a fresh one fails.
  11. must-revalidate: The cache must revalidate the resource with the origin server once it becomes stale.
  12. proxy-revalidate: Similar to must-revalidate, but only for shared caches.
  13. immutable: Indicates that the response body will not change over time.
  14. **n...
senior

senior

Gợi ý câu hỏi phỏng vấn

senior

Which type of Webservices methods are to be idempotent?

middle

What is statelessness in RESTful Webservices?

middle

What is the use of Accept and Content-Type Headers in HTTP Request?

Bình luận

Chưa có bình luận nào

Chưa có bình luận nào