#113 closed enhancement (fixed)
Add apache ExpiresByType equivalent functionality
| Reported by: | thermal7.myopenid.com | Owned by: | somebody |
|---|---|---|---|
| Priority: | minor | Milestone: | |
| Component: | nginx-core | Version: | 1.0.x |
| Keywords: | Cc: | ||
| uname -a: | not applicable | ||
| nginx -V: | not applicable | ||
Description
Add apache ExpiresByType equivalent functionality. The closest thing in nginx at the moment is:
# CSS and Javascript
location ~* \.(?:css|js)$ {
expires 1Y;
access_log off;
add_header Cache-Control "public";
}
which is not ideal as the content type is a more reliable way to identify the type of a file. For example http://clientdependency.codeplex.com/ results in a URI of something like /DependcyHandler.axd?asfasdkfjashdfkashdfjkhasdk
I think this would best be done by something like
# CSS and Javascript
content_type text/css, text/javascript {
expires 1Y;
access_log off;
add_header Cache-Control "public";
}
or
# CSS and Javascript
for_header "content-type" > text/css, text/javascript {
expires 1Y;
access_log off;
add_header Cache-Control "public";
}
Change History (2)
comment:1 by , 11 years ago
comment:2 by , 11 years ago
| Resolution: | → fixed |
|---|---|
| sensitive: | → 0 |
| Status: | new → closed |
The expires directive now supports variables, and this allows to do something like:
map $sent_http_content_type $expires {
default off;
image/jpeg 1w;
}
expires $expires;
Thanks to all involved.
Note:
See TracTickets
for help on using tickets.

In 4983f7d18fe36859a700cee06b162ae12aff5fa0/nginx: