0

Likewise in Apache is there a way you can setup multiple headers in nginx?

      location ~.*\.(css|html|js)$ {
      expires 30d;

I currently have that set, but I was thinking to make js and css expire after 90 days instead.

Is that possible?

Mark Henderson
  • 68,823
  • 31
  • 180
  • 259
Chirag
  • 271
  • 1
  • 4
  • 11

2 Answers2

2

Yes, you can. See the HttpHeaders and HttpHeadersMore modules.

Why would you need multiple headers to do that, though? It seems this would suffice:

   location ~.*\.html$ {
     expires 30d;
   }
   location ~.*\.(css|js)$ {
     expires 90d;
   }
AlexD
  • 8,747
  • 2
  • 29
  • 38
Eduardo Ivanec
  • 14,881
  • 1
  • 37
  • 43
  • Thanks will look into this. Though I temporarily had Apache serve those files and for now that seems to be working. – Chirag Jun 08 '11 at 19:50
0

Generally, you don't want to cache HTML pages, since they are usually static assets like CSS/JS. If you ever decide to change your HTML files, with your current 30d expires setup browsers which have already visited the site within 30 days will not request the new page.

If you, in fact, know that your HTML pages are NOT going to change except until a specific date, then you can use Expires with a given date instead of just a general 30days form when the request is served.

But you probably don't want to cache HTML...

ehc
  • 111
  • 1