3

So I've this response header for static files on my nginx server.

Cache-Control:max-age=2592000
Connection:keep-alive
Date:Sat, 11 Dec 2010 22:28:13 GMT
Expires:Mon, 10 Jan 2011 22:28:13 GMT
Last-Modified:Sat, 11 Dec 2010 22:11:35 GMT
Server:nginx/0.6.32

I think of removing the server signature to reduce the response size. What should I add in my server configuration to make the browser to use files not even making a request to server and overall make it as efficient as possible? Currently I could get the js on server this fast: http://i55.tinypic.com/orrons.png

Edit: I know added this property: add_header cache-control public; And the response headers are like this:

Cache-Control: max-age=31536000
Cache-Control: public

Because I've the expires 1y; set too. Is there a way to join them?

Also I checked facebook javascript file responses and they use these techniques:

HTTP/1.1 200 OK
Content-Type: application/x-javascript; charset=utf-8
Last-Modified: Sat, 01 Jan 2000 00:00:00 GMT
Pragma:
Content-Encoding: gzip
X-Cnection: close
Content-Length: 11724
Vary: Accept-Encoding
Cache-Control: public, max-age=31239788
Expires: Thu, 08 Dec 2011 23:43:19 GMT
Date: Sun, 12 Dec 2010 10:00:11 GMT
Connection: keep-alive

What did the Vary property do? I think I will apply the last-modified for years ago as they did.

3
  • 1
    Nginx does not allow you to remove the Server header. As a side note, you really need to upgrade your nginx version! You're on 0.6.x and latest stable is 0.8.x, there are known security vulnerabilities in your version. Dec 12, 2010 at 0:04
  • Doesn't server_tokens off make nginx not send the server header? Jan 11, 2011 at 21:17
  • Okay, I just tested it, it only takes off the version… bummer. Jan 11, 2011 at 21:22

3 Answers 3

0

This is not related to caching but since you are comparing your headers to that of facebook I assume your concern is to improve the user experience of your site.

One this I see missing from your header is compression. nginx and other Webservers allow you to compress the content before sending it to the client, significantly reducing the amount total data transfer.

You can use the link below to configure compression on your instance of nginx.

http://www.devcha.com/2010/02/enable-gzip-compression-of-nginx.html

When doing compression be sure to handle older MSIE browsers which don't handle compression very well. There is more info in a Related post

Secondly, if possible use a different domain for your static content. This will reduce the client request size because the cookie will not be passed. Example Yahoo used yimg.com for its static content i.e JS,CSS, images

0

The If-Modified-Since request-header field is used with a method to make it conditional: if the requested variant has not been modified since the time specified in this field, an entity will not be returned from the server; instead, a 304 (not modified) response will be returned without any message-body.

   If-Modified-Since = "If-Modified-Since" ":" HTTP-date

An example of the field is:

   If-Modified-Since: Sat, 29 Oct 1994 19:43:31 GMT

A GET method with an If-Modified-Since header and no Range header requests that the identified entity be transferred only if it has been modified since the date given by the If-Modified-Since header. The algorithm for determining this includes the following cases:

you already have the max-age so that will apply as well

you want to cache and also get conditional GET so no response is sent to the client

0

Silviud is talking about a header that is sent by the client as part of the request to the server so that the server knows whether to send a 304 Not Modified or the entire content of the file/page as a response.

While removing the Server header will do no harm, it won't do that much good either except for the case of tiny (e.g., Not Modified) responses. You may want to consider adding "public" to your Cache-control header to explicitly state that shared caches may cache the content.

1
  • Check the main post, edited.
    – Rihards
    Dec 12, 2010 at 9:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .