etag

HTTP缓存机制

天涯浪子 提交于 2019-12-05 10:04:39
Web 缓存大致可以分为:数据库缓存、服务器端缓存(代理服务器缓存、CDN 缓存)、浏览器缓存。 浏览器缓存也包含很多内容: HTTP 缓存、indexDB、cookie、localstorage 等等。这里我们只讨论 HTTP 缓存相关内容。 在具体了解 HTTP 缓存之前先来明确几个术语: 缓存命中率:从缓存中得到数据的请求数与所有请求数的比率。理想状态是越高越好。 过期内容:超过设置的有效时间,被标记为“陈旧”的内容。通常过期内容不能用于回复客户端的请求,必须重新向源服务器请求新的内容或者验证缓存的内容是否仍然准备。 验证:验证缓存中的过期内容是否仍然有效,验证通过的话刷新过期时间。 失效:失效就是把内容从缓存中移除。当内容发生改变时就必须移除失效的内容。 浏览器缓存主要是 HTTP 协议定义的缓存机制。HTML meta 标签,例如 <META HTTP-EQUIV="Pragma" CONTENT="no-store"> 含义是让浏览器不缓存当前页面。但是代理服务器不解析 HTML 内容,一般应用广泛的是用 HTTP 头信息控制缓存。 浏览器缓存分类 浏览器缓存分为强缓存和协商缓存,浏览器加载一个页面的简单流程如下: 浏览器先根据这个资源的http头信息来判断是否命中强缓存。如果命中则直接加在缓存中的资源,并不会将请求发送到服务器。 如果未命中强缓存

ETags, IIS7, Kernel Cache Policy (enableKernelCache)

跟風遠走 提交于 2019-12-05 08:47:08
Two-part question (parts are closely related): with the default OOTB ETag policy that IIS7 employs, why don't we see the If-None-Match/304 interaction as we navigate through pages? The headers returned for an empty-cache request, for instance, are: Content-Type image/png Last-Modified Thu, 03 Dec 2009 15:51:56 GMT Accept-Ranges bytes Etag "a8a0628a3074ca1:0" Server Microsoft-IIS/7.0 X-Powered-By ASP.NET Date Tue, 22 Dec 2009 19:47:36 GMT Content-Length 1780 ...and yet subsequent accesses to the page don't generate a 304 round-trip for the image? Also, the default applicationHost file for IIS7

Browser cache expiration for js and css files with wildfly

陌路散爱 提交于 2019-12-05 08:24:42
I have a angularjs javascript app packaged in a webapp deployed to Wildfly 8.2.1. Sometimes, when I deploy javascript or css modifications to this webapp, users have to manually delete their browser cache for the modifications appear. Is there a way to change this behavior so users don't have to delete their browser cache every time? I've shared a Gist article about that. It describes how to configure response headers in wildfly undertow subsytem to tune expiration cache headers in server http response, for specific static contents such as .js, .css, ... files. 来源: https://stackoverflow.com

How do i use Cache Control and ETag to set http headers

耗尽温柔 提交于 2019-12-05 08:09:48
I want to use Cache Control and ETag in my joomla website as suggested by google. But have no idea how to do that. I googled it a lot but could not find any worty example. Can anybody tell me how to do that..?? For Cache Control i have found this example, but is this the complete syntax..?? and where to place it in <head> tag of the index.php file??. Also please tell me the syntax of ETag and the place where to write it. You can use your .htaccess file at the root of your website for this. You'll find lots of variations on the specifics, here's a comprehensive one from http://www.siteground

php eTag generation using php

北城以北 提交于 2019-12-05 07:04:47
问题 This PHP code generates an eTag for an xml file. The problem is eTag updates only when the file it self is updated/modified. I need the etag to update when the dynamic results are updated as well. any idea how this can be done? //get the last-modified-date of this very file $lastModified=filemtime(__FILE__); //get a unique hash of this file (etag) $etagFile = md5_file(__FILE__); //get the HTTP_IF_MODIFIED_SINCE header if set $ifModifiedSince=(isset($_SERVER['HTTP_IF_MODIFIED_SINCE']) ? $

Ruby on Rails, how to disable/turn off ETag

回眸只為那壹抹淺笑 提交于 2019-12-05 04:06:55
Greetings, How do I turn off ETag(s) in Ruby on Rails v2.3.5 When I do a direct request to to the RoR/Mongrel an ETag header is present. TIA, -daniel malik much easier: config.middleware.delete Rack::ETag Putting response.etag = nil in a before_filter does not work. The etag is generated just before the response is send (it's caluculated from the body so after all rendering has been done). The proper workaround to disable etag use and generation (and so save the time spend in md5) it this monkey patch: module ActionController class Request # never match any incomming etag def etag_matches?

Set ETag for FileResult - MVC 3

蓝咒 提交于 2019-12-05 03:40:27
MVC 3 RTM. I have an action that returns a file (image/jpeg). I am trying to set the ETag for a file with no success (the etag doesn't come through on header). I have tried both Response.Cache.SetETag and Response.AppenderHeader. If I add my own custom header tag, it works as expected, it just seems to be ETag that I can't set. Here is the source. [HttpGet, OutputCache(Location= OutputCacheLocation.Client, VaryByParam="userId", Duration=3600, NoStore=true)] public ActionResult GetImage(string userId) { byte[] result; using (var client = new WebClient()) { client.Credentials = CredentialCache

Remove Etag from favicon.ico

旧街凉风 提交于 2019-12-05 01:27:58
问题 using yslow on a project I am experiencing a "problem" I can not solve. Yslow keeps complaining: There is 1 component with misconfigured ETags http://www.domain.com/favicon.ico I have the following in my .htaccess file # Add Proper MIME-Type for Favicon AddType image/x-icon .ico # Enable Apache's mod_expires Module ExpiresActive On ExpiresByType image/x-icon "access plus 6 month" <ifModule mod_headers.c> Header unset ETag </ifModule> FileETag None Does anybody have an idea how to fix it? 回答1:

Using ETag / Last-Modified decorators with Django's class-based generic views

拈花ヽ惹草 提交于 2019-12-04 20:47:29
问题 I've recently migrated all views in one of my Django projects to the new class-based ones. For classic function-based Django views there's a handy decorator django.views.decorators.http.condition that can be used to bypass the whole view processing if there's a cached copy matching the conditions that you've specified. I've searched everywhere in the docs and in the source code but can't find any implementation of this for the new class-based views. So my question is: How would you suggest

304 Not Modified When If-None-Match is valid

荒凉一梦 提交于 2019-12-04 12:31:35
问题 I am optimizing an Express JSON API for consumption by iOS & Android Apps and do not seem to be able to get Express to respond with the correct 304 header when the Apps specify an etag within the If-None-Match header. I needn't setup Etag generation as Express was already providing those; however when the Apps specify that etag again in a second request; Express' response is still a 200 with the data, as you can see in my tests in Postman: How can I enable this functionality? Update: The iOS