configuring e-tags

前端 未结 8 1376
有刺的猬
有刺的猬 2021-02-01 15:49

I am using Yslow as a simple speed benchmarking tool and I came across a really confusing concept. The E-tag

So the main problem is : How do I configure E-tags? my grade

相关标签:
8条回答
  • 2021-02-01 16:09

    wikipedia is the man's best friend:)

    http://en.wikipedia.org/wiki/HTTP_ETag

    Basically a hash as ShZ said, that should be unique or almost for a file.

    0 讨论(0)
  • 2021-02-01 16:11

    The best way to configure your ETags is to remove them. For static files, far-future expiration dates are a much better approach.

    The way to remove them depends on the web server you're using. For IIS 7, it can be done with a simple HttpModule.

    0 讨论(0)
  • 2021-02-01 16:12

    Entity tags are a feature of the HTTP protocol, see http://www.ietf.org/rfc/rfc2616.txt

    Entity tags are used for comparing two or more entities from the same requested resource. HTTP/1.1 uses entity tags in the ETag (section 14.19), If-Match (section 14.24), If-None-Match (section 14.26), and If-Range (section 14.27) header fields. The definition of how they are used and compared as cache validators is in section 13.3.3. An entity tag consists of an opaque quoted string, possibly prefixed by a weakness indicator.

    0 讨论(0)
  • 2021-02-01 16:19

    Assuming you are running Apache...

    You can set up a simple ETag like this:

    FileETag MTime Size
    

    If you have multiple servers, you want to disable ETags.

    FileETag None
    

    Put the above code in your httpd.conf (if you have access), otherwise you can put it in .htaccess.

    0 讨论(0)
  • 2021-02-01 16:20

    By removing the ETag header, you disable caches and browsers from being able to validate files, so they are forced to rely on your Cache-Control and Expires header.

    Add these lines to .htaccess:

    <ifModule mod_headers.c>   
    Header unset ETag
    </ifModule>
    FileETag None
    
    0 讨论(0)
  • 2021-02-01 16:22

    Go straight to the source, YSlow provides guidance on all of it's advice, including how to configure ETags.

    0 讨论(0)
提交回复
热议问题