2013年4月13日

规则13 配置ETag

摘要: 1. ETag a. ETag(实体标签 Entity Tag)是web服务器和浏览器用于确认缓存组件的有效性的一种机制; b. 如果缓存过期了,则会发送一个条件GET请求进行有效性检查(和没设置Expires或max-age一样 Cache-Control:no-store才意味着不缓存);若用户明确加载(refresh or reload)则会发送一个max-age:0【刷新缓存有效期】的条件GET请求;组件仍有效服务器则返回340 Not Modified。 c. 服务器检测缓存组件是否和服务器组件匹配有两种方式:比较最新修改时间 和 比较实体标签。2. ETag存在的问题 a.... 阅读全文

posted @ 2013-04-13 21:59 BigPalm 阅读(515) 评论(0) 推荐(0) 编辑

规则12 移除重复脚本

摘要: 1. 导致重复脚本的主要因素:团队大小和脚本数量。2. 重复脚本损伤性能 a. 不必要的HTTP请求 重复脚本无长久缓存时(没设置Expires),会产生两次HTTP请求。第一次会产生一次脚本请求,一次条件GET请求;第二次会产生两次条件GET请求; 重复脚本有长久缓存时(设置Expires),第一次会产生一次HTTP请求,第二次就不会产生缓存(但刷新页面会产生二次max-age=0【刷新缓存有效期】的条件GET请求); b. 执行Javascript所浪费的时间 脚本会多次执行。3. 避免重复脚本——实现一个脚本管理模块 a. HTML中:<script type="... 阅读全文

posted @ 2013-04-13 21:20 BigPalm 阅读(197) 评论(0) 推荐(0) 编辑

HTTP头的Expires与Cache-control

摘要: 原文地址:http://www.cnblogs.com/yuyii/archive/2008/10/16/1312238.html1.概念Cache-control用于控制HTTP缓存(在HTTP/1.0中可能部分没实现,仅仅实现了Pragma: no-cache)数据包中的格式:Cache-Control:cache-directivecache-directive可以为以下:request时用到:| "no-cache"| "no-store"| "max-age" "=" delta-seconds| &qu 阅读全文

posted @ 2013-04-13 20:42 BigPalm 阅读(111) 评论(0) 推荐(0) 编辑

规则11 避免重定向

摘要: 1. 重定向 a. 重定向(Redirect)用于将用户从一个URL重新路由到另一个URL; b. 重定向有很多种——301和302最常用; c. 通常针对HTML文档进行重定向,但通常也能用在请求页面的组件(图片、脚本等); d. 使用重定向的原因:网站重新设计、跟踪流量、记录广告点击、建立易于记忆的URL; e. 重定向会让页面变慢。2. 重定向类型 300 Multiple Choices(基于Content-Type); 301 Moved Permancently 302 Moved Temporarily 303 See Other(对302的说明) 304 N... 阅读全文

posted @ 2013-04-13 19:47 BigPalm 阅读(538) 评论(0) 推荐(0) 编辑

规则10 精简JavaScript

摘要: 1. 精简和混淆 精简是从代码中移除不必要的字符以减小其大小,进而改善加载时间的实践; 混淆也会移除注释和空白,同时它还会改写代码,函数和变量的名字将被转换为更短的字符串;(可能引入错误,维护麻烦,调试困难) 精简有工具JSMin(有很多语言版本),混淆有工具DojoCompressor(改名为ShrinkSafe); 内联脚本也应该精简,而且比外部文件简单,可以直接用后端语言版本的JSMin集成。2. 压缩和精简 压缩比精简节省更多,精简后压缩和混淆后压缩性能差别不大,但精简不具有混淆带来的风险,所以建议精简后压缩。3. 精简CSS CSS中的注释和空白比JavaScript少,... 阅读全文

posted @ 2013-04-13 15:35 BigPalm 阅读(135) 评论(0) 推荐(0) 编辑

规则9 减少DNS查找

摘要: 1. DNS DNS就是URL和实际宿主服务器之间的一个间接层,将主机名映射到IP地址上。 如果一个服务器被另外一个具有不同IP地址的服务器替代了,DNS允许用户用同样的主机名来连接到新的服务器。可以将多个IP地址关联到一个主机名,为网站提供高冗余度。2. DNS和TTL a. DNS可以被DNS服务器(ISP或局域网的一台特殊的缓存服务器)、操作系统、浏览器缓存; b. 只要浏览器在其缓存中保留了DNS记录,就无需请求操作系统。浏览器丢弃该记录时,就会向操作系统询问IP地址,操作系统或者通过其DNS缓存响应,或者将请求发送给远程DNS服务器; c. 考虑到IP地址变化以及缓存会消耗... 阅读全文

posted @ 2013-04-13 15:06 BigPalm 阅读(419) 评论(0) 推荐(0) 编辑

Newton method

摘要: 1. Guide Let'snow talk about a different algorithm for minimizing l(θ).2.Newton method To get us started, lets consider Newton’s method for finding a zero of afunction. Specifically, suppose we have some function f : R → R, and wewish to find a value of θ so that f(θ) = 0. Here, θ ∈ R is a real 阅读全文

posted @ 2013-04-13 12:14 BigPalm 阅读(269) 评论(0) 推荐(0) 编辑

The perceptron learning algorithm

摘要: 1. Guide Consider modifying the logistic regression method to “force” it tooutput values that are either 0 or 1 or exactly. To do so, it seems natural tochange the definition of g to be the threshold function: If we then let h(x) = g(θT x) as before but using this modified definition ofg,... 阅读全文

posted @ 2013-04-13 11:46 BigPalm 阅读(265) 评论(0) 推荐(0) 编辑

Classification and logistic regression

摘要: 1. Guide Classification:This is just like the regressionproblem, except that the values y we now want to predict take on onlya small number of discrete values. For now, we will focus on the binaryclassification problem in which y can take on only two values, 0 and 1.0 is also called the negative c.. 阅读全文

posted @ 2013-04-13 11:32 BigPalm 阅读(377) 评论(0) 推荐(0) 编辑

Locally weighted linear regression

摘要: 1. Guide The leftmost figure shows the result of fitting ay = θ0 + θ1x1 to a dataset.We see that the datadoesn’t really lie on straight line, and so the fit is not very good. This is called underfitting.---there is only one feature, it's too few. So, we add an extra feature x12, and fity =... 阅读全文

posted @ 2013-04-13 10:39 BigPalm 阅读(519) 评论(0) 推荐(0) 编辑

Probabilisic interpretaion

摘要: 1. Guide When faced with a regression problem, why might linear regression, andspecifically why might the least-squares cost function J, be a reasonablechoice? In this section, we will give a set of probabilistic assumptions, underwhich least-squares regression is derived as a very natural algorith. 阅读全文

posted @ 2013-04-13 09:44 BigPalm 阅读(186) 评论(0) 推荐(0) 编辑

导航