Curl/Bash code for HTTP Headers Prevent Caching ExampleThis Curl/Bash code snippet was generated automatically for the HTTP Headers Prevent Caching example.
<< Back to the HTTP Headers Prevent Caching example
What are HTTP Headers?
The HTTP headers enable clients to send additional information to the server and enable the server to provide additional information to clients. The HTTP header is invisible to the end-user and can only be seen by clients, servers, and network administrators. The purpose of Custom HTTP headers is to provide additional information related to the current request or response to help with troubleshooting. HTTP headers contain a case-insensitive name followed by a colon ":" and its value. Spaces before the value are ignored.
What is Cache-Control?
The Cache-control is an HTTP header specifying the caching policies for client requests and server responses. Caching policies specify how the resource is cached, where it is cached, and how long it can be cached before it expires.
What is Pragma?
The Pragma is a non-cache header in HTTP/1.0 that is intended to be used in the request-response chain. A pragma header is meant to prevent the client from caching the response, which indicates the browser wants a fresh version from the server.
What is Expires?
The Expires HTTP header specifies the date/time after which a response is considered expired. Usually, the lifetime of a resource is set via the Expires header, but if you need to be more specific, you can set the "max-age" parameter in seconds. And this directive takes precedence over Expires, but it's always a good idea to set this header for backward compatibility. Invalid expiration dates with a value of 0 represent a date in the past and mean that the resource is already expired.
HTTP Headers to Prevent Caching Syntax
The following is the correct minimum set of headers to prevent caching:
How to prevent caching with HTTP headers?
The following is an example of preventing caching with HTTP headers:
Server response to our prevent caching request: