Forum: NGINX Will nginx support HTTP Etag ?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
8a178ad712b49bd3d8031e00dfe1e3fd?d=identicon&s=25 Xia Qingran (Guest)
on 2009-04-14 11:47
(Received via mailing list)
Hi,
After reading http://wiki.nginx.org, I find out that nginx has not the
offical support for the HTTP Etag,
http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.... . I
want to know whether the future version of nginx will add this
feature.

My website is taking use of nginx to run static files server including
lots of Javascipt and CSS files modified frequently. Now I set a very
short expires time like, expires 1h, to renew the client cache as soon
as possible.

But I think it is not a good solution. It wastes my network bandwidth
if I do not modify the static files. Etag will do it better because it
can renew the client's cache immediately. Moreover the implement of
this feature is not very hard. One simple method of generating the
ETag is based on the the size and last modified time of the file.

Regards,
--
夏清然
Xia Qingran
qingran.xia@gmail.com
Sent from Beijing, 11, China
Henny Youngman  - "I told the doctor I broke my leg in two
places. He told me to quit going to those places." -
http://www.brainyquote.com/quotes/authors/h/henny_...
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-04-14 12:12
(Received via mailing list)
Xia Qingran wrote:
>
> But I think it is not a good solution. It wastes my network bandwidth
> if I do not modify the static files.

If last-modifed date of file is not changed, bandwidth saved:

client send in request

header If-Modified-Since:

and if time in request same as time of file modification on disk nginx
send reply
HTTP/1.x 304 Not Modified

In general Etag for static files is not better than Last-Modified
header.

Etag is useful for dynamic content, when modify time is not known. In
this case Etage can be
generated from hash (md5/sha) of content.
F5a6ed477b109fe6acc11a5a8f87e7e8?d=identicon&s=25 Michael Shadle (Guest)
on 2009-04-14 17:55
(Received via mailing list)
2009/4/14 Xia Qingran <qingran.xia@gmail.com>:
> as possible.
>
> But I think it is not a good solution. It wastes my network bandwidth
> if I do not modify the static files. Etag will do it better because it
> can renew the client's cache immediately. Moreover the implement of
> this feature is not very hard. One simple method of generating the
> ETag is based on the the size and last modified time of the file.


Do what (I do) and other large sites do.

Put a query string parameter on the file. It will make the browser
treat it as a fresh one.

foo.js
foo.js?v=1
foo.js?v=2

(Somewhat thanks to Flickr for validating this concept)

It is also CDN friendly, we use Akamai and it allows us to not have to
purge the cache constantly.

We use our subversion revision number for the ID that goes in the v=
param. This automates it and there is no way for the file to be
updated without going through subversion anyway; it's kind of a
win/win. I find this to be easy and require less configuration.
However, if you don't have an automated system you'll have to remember
when you update your .js file to go update the calling page (which
might be just as simple too)

Yahoo discourages ETags as well depending on your usage model:

"If you're not taking advantage of the flexible validation model that
ETags provide, it's better to just remove the ETag altogether. The
Last-Modified header validates based on the component's timestamp. And
removing the ETag reduces the size of the HTTP headers in both the
response and subsequent requests."[1]

[1] http://developer.yahoo.com/performance/rules.html
8a178ad712b49bd3d8031e00dfe1e3fd?d=identicon&s=25 Xia Qingran (Guest)
on 2009-04-15 05:03
(Received via mailing list)
Thanks a lot for Michael and Anton's replies and good suggestion!

On Tue, Apr 14, 2009 at 11:36 PM, Michael Shadle <mike503@gmail.com>
wrote:
>> short expires time like, expires 1h, to renew the client cache as soon
>
> purge the cache constantly.
>
> "If you're not taking advantage of the flexible validation model that
> ETags provide, it's better to just remove the ETag altogether. The
> Last-Modified header validates based on the component's timestamp. And
> removing the ETag reduces the size of the HTTP headers in both the
> response and subsequent requests."[1]
>
> [1] http://developer.yahoo.com/performance/rules.html
>
>



--
夏清然
Xia Qingran
qingran.xia@gmail.com

Henny Youngman  - &quot;I told the doctor I broke my leg in two
places. He told me to quit going to those places.&quot; -
http://www.brainyquote.com/quotes/authors/h/henny_...
4eac1f7d1ff86ab17e7a9dbe6af0b44b?d=identicon&s=25 Phillip B Oldham (Guest)
on 2009-04-15 09:46
(Received via mailing list)
Attachment: phill.vcf (262 Bytes)
Anton Yuzhaninov wrote:
> In general Etag for static files is not better than Last-Modified header.
>
> Etag is useful for dynamic content, when modify time is not known. In
> this case Etage can be generated from hash (md5/sha) of content.

Can this work with the memcached module in any way? For instance, if the
resource requested is in the memcached store then the 304 header is
sent?

--

*Phillip B Oldham*
The Activity People
phill@theactivitypeople.co.uk <mailto:phill@theactivitypeople.co.uk>

------------------------------------------------------------------------

*Policies*

This e-mail and its attachments are intended for the above named
recipient(s) only and may be confidential. If they have come to you in
error, please reply to this e-mail and highlight the error. No action
should be taken regarding content, nor must you copy or show them to
anyone.

This e-mail has been created in the knowledge that Internet e-mail is
not a 100% secure communications medium, and we have taken steps to
ensure that this e-mail and attachments are free from any virus. We must
advise that in keeping with good computing practice the recipient should
ensure they are completely virus free, and that you understand and
observe the lack of security when e-mailing us.
96321bb7fd6f712aa7785ce2d58388f2?d=identicon&s=25 Anton Yuzhaninov (Guest)
on 2009-04-15 12:02
(Received via mailing list)
Phillip B Oldham wrote:
>>
>> In general Etag for static files is not better than Last-Modified header.
>>
>> Etag is useful for dynamic content, when modify time is not known. In
>> this case Etage can be generated from hash (md5/sha) of content.
>
> Can this work with the memcached module in any way? For instance, if the
> resource requested is in the memcached store then the 304 header is sent?
>

AFAIK it is not possible now.
This topic is locked and can not be replied to.