HTTP response headers
HTTP headers are part of the HTTP protocol used to request web pages, request responses from API endpoints, and to send the response (e.g. from the web page or the API response). Some HTTP response headers are added by the WPVIP Platform and can be useful for troubleshooting.
HTTP headers are not visible when viewing web pages in a browser, nor when viewing the HTML source for a web page. To inspect request and response headers, use specific tools such as cURL or developer tools in a web browser.
Retrieve HTTP response headers in a terminal
cURL commands can be used in a terminal on a user’s local machine to retrieve all HTTP response headers for a request, or to retrieve a specific HTTP response header for a request.
All HTTP response headers
Run a curl
command with the -I
option to fetch HTTP response headers for a URL. The -I
option informs cURL to only fetch the HTTP headers (HEAD
method) of a particular page or resource and not the entire response.
In this example cURL command output, the HTTP headers indicate that the request was intercepted by the edge cache server located in Sydney, Australia (x-rq: syd1 123 243 443
) and the response is from origin (x-cache: MISS
).
$ curl -I "https://docs.wpvip.com/"
HTTP/2 200
server: nginx
date: Tue, 12 Nov 2024 00:14:52 GMT
content-type: text/html; charset=UTF-8
vary: Accept-Encoding
x-hacker: If you're reading this, you should visit wpvip.com/careers and apply to join the fun, mention this header.
x-powered-by: WordPress VIP <https://wpvip.com>
host-header: a9130478a60e5f9135f765b23f26593b
link: <https://docs.wpvip.com/wp-json/>; rel="https://api.w.org/"
link: <https://docs.wpvip.com/wp-json/wp/v2/pages/981>; rel="alternate"; title="JSON"; type="application/json"
link: <https://docs.wpvip.com/>; rel=shortlink
x-rq: syd1 123 243 443
accept-ranges: bytes
x-cache: MISS
cache-control: max-age=300, must-revalidate
A specific HTTP response header
Use curl -Is
and grep
to output only a specific HTTP response header. The -s
option is included to apply “silent mode” and omit progress meters or error messages for the command.
In this example cURL command and output, the x-cache
HTTP response header is requested, and the x-cache: HIT
value that is returned indicates that the response was served from the page cache.
$ curl -Is "https://docs.wpvip.com/" | grep x-cache
x-cache: HIT
In this example cURL command and output, the x-rq
HTTP response header is requested, and the x-rq: syd1 123 243 443
value that is returned indicates that the response was served by an edge cache server in Sydney, Australia (syd
).
$ curl -Is "https://docs.wpvip.com/" | grep x-rq
x-rq: syd1 123 243 443
Retrieve HTTP response headers in a web browser
The x-cache
and x-rq
HTTP response headers for a specific URL can also be retrieved in a web browser’s developer tools.
Open the developer tool interface for a web browser and navigate to the section for “network” requests. Load a URL in the browser’s address bar and select the request for that URL from the list of requests in the network panel. The develop tool panel should display an additional panel where all headers for the response can be inspected, including the x-cache
and x-rq
HTTP response headers.
Last updated: November 26, 2024