etag

How do I return 304 Unmodified status with Express.js?

守給你的承諾、 提交于 2019-12-04 12:18:42
I'm using node and express for the back end of an iOS application. Data is stored in a SQL Server database, so iOS apps query the server, the server queries the database, server receives the db response, and then forwards the response to the iOS application. I'm trying to figure out how caching works though. I'm serving a lot of static content - blog articles for example. So I planned to use etags, but I'm not sure how it's supposed to work. I make a request, get content, and cache the response on the client side. Ok. Then I make the same request later with the etag of the previous response

Is it possible to set ETags using JAX-RS without resorting to Response objects?

家住魔仙堡 提交于 2019-12-04 08:28:47
问题 In one of the few questions (with answers) I have found on SO regarding JAX-RS and caching, the answer to generating ETags (for caching) is by setting some values on the Response object. As in the following: @GET @Path("/person/{id}") public Response getPerson(@PathParam("id") String name, @Context Request request){ Person person = _dao.getPerson(name); if (person == null) { return Response.noContent().build(); } EntityTag eTag = new EntityTag(person.getUUID() + "-" + person.getVersion());

加速网站的最佳实践

人走茶凉 提交于 2019-12-04 03:25:24
Exceptional Performance团队已经确定了许多快速制作网页的最佳实践。 按类别筛选: Content Server Cookie CSS JavaScript Images Mobile All 最小化HTTP请求 tag: content 最终用户响应时间的80%用于前端。大部分时间都在下载页面中的所有组件:图像,样式表,脚本,Flash等。减少组件数量反过来减少了呈现页面所需的HTTP请求数量。这是更快页面的关键。 减少页面中组件数量的一种方法是简化页面设计。但有没有办法构建内容更丰富的页面,同时还能实现快速响应时间?以下是一些减少HTTP请求数量的技术,同时仍支持丰富的页面设计。 组合文件是一种通过将所有脚本组合到单个脚本中来减少HTTP请求数量的方法,并且类似地将所有CSS组合到单个样式表中。当脚本和样式表在不同页面之间变化时,组合文件更具挑战性,但使这部分发布过程可以缩短响应时间。 CSS Sprites是减少图像请求数量的首选方法。将背景图像合并为单个图像,并使用CSSbackground-image和background-position属性显示所需的图像片段。 图像地图将多个图像组合成单个图像。整体大小大致相同,但减少HTTP请求的数量会加快页面的速度。图像映射仅在图像在页面中是连续的时才起作用,例如导航栏。定义图像映射的坐标可能是乏味且容易出错的

页面性能优化办法有哪些?

六月ゝ 毕业季﹏ 提交于 2019-12-04 02:19:25
引子 互联网有一项著名的8秒原则。用户在访问Web网页时,如果时间超过8秒就会感到不耐烦,如果加载需要太长时间,他们就会放弃访问 。大部分用户希望网页能在2秒之内就完成加载。事实上,加载时间每多1秒,你就会流失7%的用户。8秒并不是准确的8秒钟,只是向网站开发者表明了加载时间的重要性。那我们如何优化页面性能,提高页面加载速度呢?这是本文主要要探讨的问题,然而性能优化是个综合性问题,没有标准答案,想要面面俱到罗列出来,并非易事。本文只关注一些核心要点,以下是我总结性能优化常见的办法: 一、资源压缩与合并 主要包括这些方面: html压缩、css 压缩、js的压缩和混乱和文件合并 。 资源压缩可以从文件中去掉多余的字符,比如回车、空格。你在编辑器中写代码的时候,会使用缩进和注释,这些方法无疑会让你的代码简洁而且易读,但它们也会在文档中添加多余的字节。 1.html压缩 html代码压缩就是压缩这些在文本文件中有意义,但是在HTML中不显示的字符,包括空格,制表符,换行符等,还有一些其他意义的字符,如HTML注释也可以被压缩。 如何进行html压缩: 使用在线网站进行压缩(开发过程中一般不用) nodejs 提供了html-minifier工具 后端模板引擎渲染压缩 2.css代码压缩: css代码压缩简单来说就是无效代码删除和css语义合并 如何进行css压缩: 使用在线网站进行压缩

ETag and If-None-Match HTTP Headers are not working

一个人想着一个人 提交于 2019-12-04 01:58:07
I have a file in my webserver and I am downloading that to my app everytime I access it because its possible that file content might be changed But If it is changed I would like to download that time only so bandwidth can be saved and fortunately that's what this ETag and If-None-Match header fields are for. When I make a request first time ,I retrieve the ETag from the HTTP response headers In the subsequent requests to download that file I'd attach the Etag value for If-None-Match headerfield so that if there is no change then I'd get HTTP response status code 304 or else I'd get 200 if

Safari not sending “If-Modified-Since” and “If-None-Match” headers

99封情书 提交于 2019-12-04 00:08:55
问题 I'm generating dynamic content with PHP. I'm sending the following HTTP-header: HTTP/1.1 304 Not Modified Date: Sun, 09 Dec 2012 17:24:41 GMT Server: Apache Connection: keep-alive, Keep-Alive Keep-Alive: timeout=1, max=100 Etag: "237f43b800e655dbe6567f7d32d34c99" Expires: Sun, 16 Dec 2012 17:24:41 GMT Cache-Control: max-age=604800 Vary: Accept-Encoding I later check for the Etag to send a header('HTTP/1.1 304 Not Modified') if it matches. This works perfectly with Chrome and Firefox. However,

Etags and last-modified over https SSL?

我是研究僧i 提交于 2019-12-03 17:36:57
问题 Is it possible to use HTTP caching for conditional GET requests over a secure HTTPS connection? I've got caching working over non-secure HTTP, but when I switch to HTTPS the browser stops sending if-none-match and if-modified-since headers, so the caching breaks. I've tried various Cache-Control settings like public, max-age=3600 and whatnot, no dice. This happens in both Safari and Chrome, so I'm assuming the SSL is breaking it somehow. Is caching not allowed over SSL? And just to be clear,

Remove Etag from favicon.ico

核能气质少年 提交于 2019-12-03 15:31:45
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? Yavane Add this: ExpiresByType image/ico "access plus 1 years" My .htaccess file: <IfModule mod_expires.c>

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

泪湿孤枕 提交于 2019-12-03 14:02:17
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 that I implement conditional view processing for class-based views? It looks like there isn't a nice

Rails - etags vs. page caching (file cache)

醉酒当歌 提交于 2019-12-03 13:40:38
问题 What would be some advantages of using etags/stale?/fresh_when? instead of page caching (on a file cache)? Apache automatically handles etags for static files, but even if it didn't, page caching would still be better since the Rails app doesn't even get called. So, in what instances would I use the methods provided by Rails (stale?/fresh_when?)? 回答1: They are really complimentary. Etags/fresh_when etc. help you play nice with downstream caches (like your own Varnish/Squid instances or Rack: