Need to add expires header conditionally based on mime types
António P. P. Almeida
appa at perusio.net
Fri Jun 14 06:35:54 UTC 2013
If you use the Lua embedded module you can do that AFAICT.
http://wiki.nginx.org/HttpLuaModule#header_filter_by_lua
Le 14 juin 2013 05:42, "Silver Moon" <m00n.silv3r at gmail.com> a écrit :
> the
>
> putting $upstream_http_content_type or $sent_http_content_type or
> $content_type inside "if" does not work.
> i wish someone could test and provide a working example.
>
> none of the samples shown in the stackoverflow post work.
>
> i tested enough and found that only $sent_http_content_type contains the
> http response Content-type
> and that can be tested like this
>
> add_header TEST $sent_http_content_type
>
> however putting that inside an if and trying to add further headers inside
> that if will not work
> i opened a ticket in trac and they said that it does not work like that
>
> however no one confirms if it is strictly possible or impossible.
>
> On Fri, Jun 14, 2013 at 10:00 AM, Miguel Clara <miguelmclara at gmail.com>wrote:
>
>> From what you describe I do think the suggested nginx config is
>> enough...
>>
>> However maybe you're looking for something like this:
>>
>>
>> http://stackoverflow.com/questions/14631044/expires-header-based-on-dynamic-content-type-in-nginx
>>
>> Not really sure if it suits you're needs, but It seems this is what
>> you're looking for.
>>
>> You can also find more info on mime type here:
>> http://wiki.nginx.org/HttpCoreModule#types
>>
>> Hope this helps,
>>
>> Mike
>>
>>
>>
>> On 06/14/13 03:12, Silver Moon wrote:
>>
>> yes, i could send out headers from php itself
>> but mime based header generation in the webserver itself would make
>> things easier.
>>
>> so finally it is impossible to achieve that ?
>>
>> On Fri, Jun 14, 2013 at 8:35 AM, Host DL <hostdl at gmail.com> wrote:
>>
>>> If you handle your js, css and images by php scripts you can use
>>> header function to send out Expires and Cache-Control directives
>>>
>>> example:
>>>
>>> <?php
>>> header("Cache-Control: no-cache, must-revalidate"); // HTTP/1.1
>>> header("Expires: Sat, 26 Jul 1997 05:00:00 GMT"); // Date in the past
>>> ?>
>>>
>>> _______________________________________________
>>> nginx mailing list
>>> nginx at nginx.org
>>> http://mailman.nginx.org/mailman/listinfo/nginx
>>>
>>
>>
>>
>> --
>> Silver
>>
>>
>> _______________________________________________
>> nginx mailing listnginx at nginx.orghttp://mailman.nginx.org/mailman/listinfo/nginx
>>
>>
>>
>> _______________________________________________
>> nginx mailing list
>> nginx at nginx.org
>> http://mailman.nginx.org/mailman/listinfo/nginx
>>
>
>
>
> --
> Silver
>
> _______________________________________________
> nginx mailing list
> nginx at nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20130614/7f49de49/attachment.html>
More information about the nginx
mailing list