<?xml version="1.0" encoding="UTF-8"?> <rss
version="2.0"
xmlns:content="http://purl.org/rss/1.0/modules/content/"
xmlns:wfw="http://wellformedweb.org/CommentAPI/"
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
><channel><title>XmlChina! &#187; Etags</title> <atom:link href="http://www.xmlchina.org/tag/etags/feed/" rel="self" type="application/rss+xml" /><link>http://www.xmlchina.org</link> <description>互联网资讯博客</description> <lastBuildDate>Wed, 17 Mar 2010 03:40:25 +0000</lastBuildDate> <generator>http://wordpress.org/?v=2.9.2</generator> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>[原创]Nginx第三方模块ETags的两个参数</title><link>http://www.xmlchina.org/etags-third-party-module-nginx-two-parameters/</link> <comments>http://www.xmlchina.org/etags-third-party-module-nginx-two-parameters/#comments</comments> <pubDate>Fri, 13 Nov 2009 08:44:08 +0000</pubDate> <dc:creator>XmlChina</dc:creator> <category><![CDATA[代码]]></category> <category><![CDATA[Etags]]></category> <category><![CDATA[Nginx]]></category><guid
isPermaLink="false">http://www.xmlchina.org/?p=9394</guid> <description><![CDATA[刚刚发了一篇关于Etag的主题,发现还蛮多人讨论的...再说一个....
模块作者演示的.是直接在/根目录使用Etag,而我们要为一些静态元素添加Etag,所以我们要将这些文件后缀添加进来.用:
location ~ .*\.(htm&#124;html&#124;gif&#124;jpg&#124;jpeg&#124;png&#124;bmp&#124;ico&#124;rar&#124;css&#124;js&#124;zip&#124;xml&#124;txt&#124;flv&#124;swf&#124;mid&#124;doc&#124;cur&#124;xls&#124;pdf&#124;txt&#124;mp3&#124;wma)$ {
expires 7d;
FileETag on;
etag_format "%X%X";
}
这里大家发现多了一个参数.etag_format,这个其实在模块的c文件中可以找到.
/*
*  Two configuration elements: `enable_etags` and `etag_format`, specified in
*  the `Location` block.
*/
typedef struct {
ngx_uint_t  FileETag;
ngx_str_t   etag_format;
} ngx_http_static_etags_loc_conf_t;
默认的参数设置是:%s_%X_%X,表现出来的就是文件名和http协议版本,如:
HTTP/1.1 200 OK
Server: XCWS/1.0
Date: Fri, 13 Nov 2009 07:50:20 GMT
Content-Type: text/html
Content-Length: 7642
Last-Modified: Fri, 13 Nov 2009 02:41:02 GMT
Connection: keep-alive
Vary: Accept-Encoding
Etag: /readme.html HTTP/1.1
User-Agent_1DDA_4AFCC73E
Expires: Fri, 20 Nov 2009 07:50:20 GMT
Cache-Control: [...]]]></description> <content:encoded><![CDATA[<p>刚刚发了一篇关于Etag的主题,发现还蛮多人讨论的...再说一个....</p><p>模块作者演示的.是直接在/根目录使用Etag,而我们要为一些静态元素添加Etag,所以我们要将这些文件后缀添加进来.用:<span
id="more-9394"></span></p><blockquote><p>location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|xml|txt|flv|swf|mid|doc|cur|xls|pdf|txt|mp3|wma)$ {<br
/> expires 7d;<br
/> FileETag on;<br
/> etag_format "%X%X";<br
/> }</p></blockquote><p>这里大家发现多了一个参数.etag_format,这个其实在模块的c文件中可以找到.</p><blockquote><p>/*<br
/> *  Two configuration elements: `enable_etags` and `etag_format`, specified in<br
/> *  the `Location` block.<br
/> */<br
/> typedef struct {<br
/> ngx_uint_t  FileETag;<br
/> ngx_str_t   etag_format;<br
/> } ngx_http_static_etags_loc_conf_t;</p></blockquote><p>默认的参数设置是:%s_%X_%X,表现出来的就是文件名和http协议版本,如:</p><blockquote><p>HTTP/1.1 200 OK<br
/> Server: XCWS/1.0<br
/> Date: Fri, 13 Nov 2009 07:50:20 GMT<br
/> Content-Type: text/html<br
/> Content-Length: 7642<br
/> Last-Modified: Fri, 13 Nov 2009 02:41:02 GMT<br
/> Connection: keep-alive<br
/> Vary: Accept-Encoding<br
/> Etag: <span
style="color: red;">/readme.html HTTP/1.1</span><br
/> User-Agent_1DDA_4AFCC73E<br
/> Expires: Fri, 20 Nov 2009 07:50:20 GMT<br
/> Cache-Control: max-age=604800<br
/> Accept-Ranges: bytes</p></blockquote><p>但是这个并没有作用,浏览器还是每次都要去服务器找这个文件并下载.形同虚设,所以我们要改这个参数设置.<br
/> 我们在FileETag   on;后面直接再加一个etag_format "%X%X"; (Etag有一个根据文件修改时间的参数值是基于标准16进制apache文件修改时间做标准的)</p><p>之后我们再执行curl命令.OK.成功了.</p><blockquote><p>$curl --head <a
href="http://www.xmlchina.org/readme.html" target="_blank">http://www.xmlchina.org/readme.html</a><br
/> HTTP/1.1 200 OK<br
/> Server: XCWS/1.0<br
/> Date: Fri, 13 Nov 2009 07:59:00 GMT<br
/> Content-Type: text/html<br
/> Content-Length: 7642<br
/> Last-Modified: Fri, 13 Nov 2009 02:41:02 GMT<br
/> Connection: keep-alive<br
/> Vary: Accept-Encoding<br
/> Etag: <span
style="color: red;">B638900D1DDA</span><br
/> Expires: Fri, 20 Nov 2009 07:59:00 GMT<br
/> Cache-Control: max-age=604800<br
/> Accept-Ranges: bytes</p></blockquote><p>最后,不建议对动态内容使用Etag,要使用,请在动态脚本里面添加.</p><p>第三方模块Etags介绍:<a
href="http://www.xmlchina.org/nginx-configuration-support-etags-module/" target="_blank">http://www.xmlchina.org/nginx-configuration-support-etags-module/</a></p> <br
style="clear:both;"/><i>请遵循“署名-非商业用途-保持一致”的创作共用协议,转载时请注明出处以及链接地址（非商业使用）</i><br
style="clear:both;"/>Copyright &copy; 2007-2009 <strong><a
href="http://www.xmlchina.org">XmlChina!</a></strong>. All rights reserved.<br
/><ul
class="related_post"><li><a
href="http://www.xmlchina.org/nginx-configuration-support-etags-module/" title="[原创]Nginx配置支持Etags模块">[原创]Nginx配置支持Etags模块</a><br
/><p>nginx默认有Expires模块,但是却没有Etags模块.按照Nginx作者Igor Sysoev的观点,他认为在对静态文件处理上,还看不出Etags比Last-Modified的好处.但...</p></li><li><a
href="http://www.xmlchina.org/nginx-automatically-install-the-script-for-cpanel/" title="Nginx自动安装脚本 For cPanel (兼容.htaccess)">Nginx自动安装脚本 For cPanel (兼容.htaccess)</a><br
/><p>为cPanel主机添加nginx服务器软件,让nginx跑前端处理静态文件,两者相比较来说,加装nginx后的资源消耗比单纯跑apache 少很多.最近对nginx自动安装脚本进行很多修改,我仔细的测...</p></li><li><a
href="http://www.xmlchina.org/nginx-virtual-host-configuration-for-the-https-certificate-startssl-free/" title="为nginx虚拟主机配置startssl免费https证书">为nginx虚拟主机配置startssl免费https证书</a><br
/><p>StartSSL是一个免费颁发SSL证书的机构,被多数有Linux 背景的软件支持(以Mozilla的Firefox和Thunderbird为首).以前IE是没有StartSSL的根证书的,以至于一段...</p></li><li><a
href="http://www.xmlchina.org/original-nginx-support-multi-site-multi-user-php-security-issues-under-the-reflection/" title="[原创]Nginx在支持php多网站多用户下安全问题思考">[原创]Nginx在支持php多网站多用户下安全问题思考</a><br
/><p>nginx为多用户多域名提供虚拟主机一直都是个问题.在php的执行上是采用fastcgi的方式运行的.php在fastcgi模式下虽然效率 有很多提升,但是也暴露出一个问题,就是安全性问题.php以f...</p></li><li><a
href="http://www.xmlchina.org/permanent-link-to-set-up-typecho/" title="Typecho 的永久链接设置">Typecho 的永久链接设置</a><br
/><p>这篇日志主要由两个部分组成,一个是nginx上使用path_info.然后是给typecho加入了永久链接设置.我是为了方便以后的维护而进行的修改.直接上一段我的Typecho的nginx虚拟...</p></li><li><a
href="http://www.xmlchina.org/nginx-perfect-solution-the-same-service-on-the-issue-of-site-access-restrictions-webshell/" title="[2010.1.11]nginx完美解决同一服务上的站点WebShell访问限制问题">[2010.1.11]nginx完美解决同一服务上的站点WebShell访问限制问题</a><br
/><p>以前曾发过一个解决的思路：
http://www.daigou.in/viewthread.php?tid=1862当时用phpspy2008测试权限，浏览等，都没有什么问题，但是没有在接近...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-27-released/" title="Nginx 0.8.27 发布">Nginx 0.8.27 发布</a><br
/><p>该版本就只是修正了一个在 0.8.25 版本中出现的漏洞,涉及到正则表达式无法在nginx(包括Windows平台)上工作的问题,
Changes with nginx 0.8.27        ...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-7-64-released/" title="Nginx 0.7.64 发布">Nginx 0.7.64 发布</a><br
/><p>该版本修复漏洞比较多.详细看一下官方升级细则
Changes with nginx 0.7.64                                        16 Nov 2009...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-26-released/" title="Nginx 0.8.26 发布">Nginx 0.8.26 发布</a><br
/><p>Nginx 0.8.25 增加了很多新特性，也存在着很多bug，因此马上又发布了一个 0.8.26 版本。看来 0.8.25 版本发布得太仓促了。Changes with nginx 0.8....</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-24-released/" title="Nginx 0.8.24 发布">Nginx 0.8.24 发布</a><br
/><p>该版本修复了4个漏洞.涉及gzip,debug,real ip和resolving.
Changes with nginx 0.8.24                               ...</p></li></ul>]]></content:encoded> <wfw:commentRss>http://www.xmlchina.org/etags-third-party-module-nginx-two-parameters/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> <item><title>[原创]Nginx配置支持Etags模块</title><link>http://www.xmlchina.org/nginx-configuration-support-etags-module/</link> <comments>http://www.xmlchina.org/nginx-configuration-support-etags-module/#comments</comments> <pubDate>Tue, 10 Nov 2009 02:49:36 +0000</pubDate> <dc:creator>XmlChina</dc:creator> <category><![CDATA[教程]]></category> <category><![CDATA[Etags]]></category> <category><![CDATA[Nginx]]></category><guid
isPermaLink="false">http://www.xmlchina.org/?p=9379</guid> <description><![CDATA[nginx默认有Expires模块,但是却没有Etags模块.按照Nginx作者Igor Sysoev的观点,他认为在对静态文件处理上,还看不出Etags比Last-Modified的好处.
但是也有人说Nginx加了Etags模块会好很多,如这个模块的作者说的那样:
I see the complete lack of Etag support as an oversight.  It’s more granular than Last-Modified, which is only accurate to the second, and only measures change along the axis of time; touching a file doesn’t change it’s content, but would force a cache miss when the cache is based on nothing but [...]]]></description> <content:encoded><![CDATA[<p>nginx默认有Expires模块,但是却没有Etags模块.按照Nginx作者Igor Sysoev的观点,他认为在对静态文件处理上,还看不出Etags比Last-Modified的好处.</p><p>但是也有人说Nginx加了Etags模块会好很多,如这个模块的作者说的那样:<span
id="more-9379"></span></p><blockquote><p>I see the complete lack of Etag support as an oversight.  It’s more granular than Last-Modified, which is only accurate to the second, and only measures change along the axis of time; touching a file doesn’t change it’s content, but would force a cache miss when the cache is based on nothing but timestamp.  Etags, on the other hand, are content-based identifiers that provide a mechanism for confirmation that the content of the file you’re reading is accurate, regardless of inconsequential fiddling or deployment on the server.</p></blockquote><p>详细内容请访问:<a
href="http://mikewest.org/2008/11/generating-etags-for-static-content-using-nginx">http://mikewest.org/2008/11/generating-etags-for-static-content-using-nginx</a>.</p><p>下面就主要说说该模块的安装,从这里可以得到源代码和安装说明:<a
href="http://wiki.github.com/mikewest/nginx-static-etags">http://wiki.github.com/mikewest/nginx-static-etags</a></p><p>环境是Debian,我们需要安装git库.一般来说直接执行:'apt-get install git'就可以了,但是debian稳定版中去除了git-core库.我们需要安装.然后nginx方面,只是在原有配置文件上增加这个模块.要查询之前你配置的参数,可以执行'/usr/local/sbin/nginx -V'.然后在后面增加这个第三方模块.关于第三方模块的使用,可以参考nginx wiki:<a
href="http://wiki.nginx.org/Nginx3rdPartyModules">http://wiki.nginx.org/Nginx3rdPartyModules</a></p><blockquote><pre>$apt-get install git git-core
$curl -O http://sysoev.ru/nginx/nginx-0.7.63.tar.gz
$tar -zxvf ./nginx-0.7.63.tar.gz
$git-clone git://github.com/mikewest/nginx-static-etags.git /usr/src/nginx-static-etags
$cd nginx-0.7.63/
$./configure --add-module=/usr/src/nginx-static-etags \
  ...(你原有配置信息)
$make</pre></blockquote><p>在这个步骤,出错通常会显示这个信息:</p><p><code>/usr/src/nginx-static-etags/ngx_http_static_etags_module.c:168:2: error: no newline at end of file<br
/> make[1]: *** [objs/addon/nginx-static-etags/ngx_http_static_etags_module.o] Error 1<br
/> make[1]: Leaving directory `/usr/src/nginx-0.7.63'<br
/> make: *** [build] Error 2</code></p><p>出错的原因是这个第三方模块的c文件的最后一行没有用空白行隔开.我们编辑一下这个c文件,在最后一行(也就是168行)增加一个空行就可以了.然后再执行make命令.</p><p>$vi /usr/src/nginx-static-etags/ngx_http_static_etags_module.c<br
/> <span
style="background-color: #ffffff;">$...<br
/> $make</span></p><p>复制到sbin位置就可以了.<br
/> $mv /usr/local/sbin/nginx /usr/local/sbin/nginx.old<br
/> $cp objs/nginx /usr/local/sbin/</p><p>最后重启nginx.</p><p>配置方面,一般将所有静态内容都配置Etags就可以了(<a
href="http://www.xmlchina.org/etags-third-party-module-nginx-two-parameters/">参数说明</a>).如下:</p><blockquote><pre>location ~ .*\.(htm|html|gif|jpg|jpeg|png|bmp|ico|rar|css|js|zip|xml|txt|flv|swf|mid|doc|cur|xls|pdf|txt|mp3|wma)$ {
      expires 7d;
      FileETag on;
      etag_format "%X%X";
}</pre></blockquote> <br
style="clear:both;"/><i>请遵循“署名-非商业用途-保持一致”的创作共用协议,转载时请注明出处以及链接地址（非商业使用）</i><br
style="clear:both;"/>Copyright &copy; 2007-2009 <strong><a
href="http://www.xmlchina.org">XmlChina!</a></strong>. All rights reserved.<br
/><ul
class="related_post"><li><a
href="http://www.xmlchina.org/etags-third-party-module-nginx-two-parameters/" title="[原创]Nginx第三方模块ETags的两个参数">[原创]Nginx第三方模块ETags的两个参数</a><br
/><p>刚刚发了一篇关于Etag的主题,发现还蛮多人讨论的...再说一个....模块作者演示的.是直接在/根目录使用Etag,而我们要为一些静态元素添加Etag,所以我们要将这些文件后缀添加进来.用:...</p></li><li><a
href="http://www.xmlchina.org/nginx-automatically-install-the-script-for-cpanel/" title="Nginx自动安装脚本 For cPanel (兼容.htaccess)">Nginx自动安装脚本 For cPanel (兼容.htaccess)</a><br
/><p>为cPanel主机添加nginx服务器软件,让nginx跑前端处理静态文件,两者相比较来说,加装nginx后的资源消耗比单纯跑apache 少很多.最近对nginx自动安装脚本进行很多修改,我仔细的测...</p></li><li><a
href="http://www.xmlchina.org/nginx-virtual-host-configuration-for-the-https-certificate-startssl-free/" title="为nginx虚拟主机配置startssl免费https证书">为nginx虚拟主机配置startssl免费https证书</a><br
/><p>StartSSL是一个免费颁发SSL证书的机构,被多数有Linux 背景的软件支持(以Mozilla的Firefox和Thunderbird为首).以前IE是没有StartSSL的根证书的,以至于一段...</p></li><li><a
href="http://www.xmlchina.org/original-nginx-support-multi-site-multi-user-php-security-issues-under-the-reflection/" title="[原创]Nginx在支持php多网站多用户下安全问题思考">[原创]Nginx在支持php多网站多用户下安全问题思考</a><br
/><p>nginx为多用户多域名提供虚拟主机一直都是个问题.在php的执行上是采用fastcgi的方式运行的.php在fastcgi模式下虽然效率 有很多提升,但是也暴露出一个问题,就是安全性问题.php以f...</p></li><li><a
href="http://www.xmlchina.org/permanent-link-to-set-up-typecho/" title="Typecho 的永久链接设置">Typecho 的永久链接设置</a><br
/><p>这篇日志主要由两个部分组成,一个是nginx上使用path_info.然后是给typecho加入了永久链接设置.我是为了方便以后的维护而进行的修改.直接上一段我的Typecho的nginx虚拟...</p></li><li><a
href="http://www.xmlchina.org/nginx-perfect-solution-the-same-service-on-the-issue-of-site-access-restrictions-webshell/" title="[2010.1.11]nginx完美解决同一服务上的站点WebShell访问限制问题">[2010.1.11]nginx完美解决同一服务上的站点WebShell访问限制问题</a><br
/><p>以前曾发过一个解决的思路：
http://www.daigou.in/viewthread.php?tid=1862当时用phpspy2008测试权限，浏览等，都没有什么问题，但是没有在接近...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-27-released/" title="Nginx 0.8.27 发布">Nginx 0.8.27 发布</a><br
/><p>该版本就只是修正了一个在 0.8.25 版本中出现的漏洞,涉及到正则表达式无法在nginx(包括Windows平台)上工作的问题,
Changes with nginx 0.8.27        ...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-7-64-released/" title="Nginx 0.7.64 发布">Nginx 0.7.64 发布</a><br
/><p>该版本修复漏洞比较多.详细看一下官方升级细则
Changes with nginx 0.7.64                                        16 Nov 2009...</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-26-released/" title="Nginx 0.8.26 发布">Nginx 0.8.26 发布</a><br
/><p>Nginx 0.8.25 增加了很多新特性，也存在着很多bug，因此马上又发布了一个 0.8.26 版本。看来 0.8.25 版本发布得太仓促了。Changes with nginx 0.8....</p></li><li><a
href="http://www.xmlchina.org/nginx-0-8-24-released/" title="Nginx 0.8.24 发布">Nginx 0.8.24 发布</a><br
/><p>该版本修复了4个漏洞.涉及gzip,debug,real ip和resolving.
Changes with nginx 0.8.24                               ...</p></li></ul>]]></content:encoded> <wfw:commentRss>http://www.xmlchina.org/nginx-configuration-support-etags-module/feed/</wfw:commentRss> <slash:comments>0</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using memcached
Page Caching using memcached (user agent is rejected)
Database Caching 45/81 queries in 0.048 seconds using disk
Content Delivery Network via cache.xmlchina.org (user agent is rejected)

Served from: www.xmlchina.org @ 2010-09-07 10:05:00 -->