: Requesting for downloadable files via HEAD I bet google is checking web pages via HTTP HEAD and HTTP GET request methods. So I'm thinking I should also allow proper header output for downloadable
I bet google is checking web pages via HTTP HEAD and HTTP GET request methods. So I'm thinking I should also allow proper header output for downloadable files from my website via HTTP HEAD request but no documentation tells me the proper way to go.
Currently this is my HTTP header for a downloadable file when one requests it from my server with either a GET or HEAD request method:
HTTP/1.1 200 OK
Date: Sun, 06 Sep 2015 06:11:29 GMT
Server: Apache
Set-Cookie: CC=something;path=/;domain=example.com;expires=Tue, 06 Oct 2015 06:11:29 GMT
X-Robots-Tag: noindex
cache-control: max-age=864000,must-revalidate
Last-Modified: Sun, 06 Sep 2015 02:39:19 GMT
content-disposition: attachment; filename="HQ_Photo8.jpg.gz"
Content-Length: 251085
X-Frame-Options: DENY
Accept-Ranges: bytes
Content-Type: application/gzip
What headers should I add or remove to comply to standards when someone requests the download via a HEAD request method?
I read with a standard html document that when one requests it with a HEAD method that the "content-length" header should be removed, but since this is a downloadable file I'm dealing with, I think its more involved.
Any ideas?
More posts by @Sent6035632
1 Comments
Sorted by latest first Latest Oldest Best
The HTTP response headers for HEAD and GET requests should be identical. The only difference is that the response body is missing from the HEAD response.
From RFC 2616 - HTTP/1.1 Section 9.4 HEAD:
9.4 HEAD
The HEAD method is identical to GET except that the server MUST NOT return a message-body in the response. The metainformation contained in the HTTP headers in response to a HEAD request SHOULD be identical to the information sent in response to a GET request. This method can be used for obtaining metainformation about the entity implied by the request without transferring the entity-body itself. This method is often used for testing hypertext links for validity, accessibility, and recent modification.
The response to a HEAD request MAY be cacheable in the sense that the information contained in the response MAY be used to update a previously cached entity from that resource. If the new field values indicate that the cached entity differs from the current entity (as would be indicated by a change in Content-Length, Content-MD5, ETag or Last-Modified), then the cache MUST treat the cache entry as stale.
There would not seem to be any reason to omit the Content-Length header from the response (unless it is perhaps computationally expensive to include it). The spec specifically mentions the inclusion of this header and if it was omitted it could reduce functionality.
I read with a standard html document that when one requests it with a HEAD method that the "content-length" header should be removed, but since this is a downloadable file I'm dealing with, I think its more involved.
Where did you read this?
There isn't really any difference between an "HTML document" and a "downloadable file".
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.