- 浏览: 286401 次
- 性别:
- 来自: 上海
文章分类
最新评论
-
onlyjing:
你好!我是猎头顾问only ,有北京知名网络安全公司高级web ...
python:web搭建 -
dr88:
有时间也来做一个,谢谢分享
Wordpress自动采集更新、发布文章插件AutoBlogged2.578最新破解版 -
Ryee:
百度赚钱依靠页面看来承载广告,所以1、增加页面2、提升单位页面 ...
百度如何赚钱 -
jeans_1312:
路过,学习一下
Wordpress自动采集更新、发布文章插件AutoBlogged2.578最新破解版 -
Ryee:
坚持喝了一周的红豆薏米汤,适当的运动量辅助排汗,湿气除的不错。 ...
夏季南方去体内湿气-养生方法
Compression is a simple, effective way to save bandwidth and speed up your site. I hesitated when recommending gzip compression when speeding up your javascript because of problems in older browsers. But it’s the 21st century. Most of my traffic comes from modern browsers, and quite frankly, most of my users are fairly tech-savvy. I don’t want to slow everyone else down because somebody is chugging along on IE 4.0 on Windows 95. Google and Yahoo use gzip compression. A modern browser is needed to enjoy modern web content and modern web speed — so gzip encoding it is. Here’s how to set it up. Before we start I should explain what content encoding is. When you request a file like 1. Browser: Hey, GET me /index.html Of course, the actual headers and protocols are much more formal (monitor them with Live HTTP Headers if you’re so inclined). But it worked, and you got your file. Well, the system works, but it’s not that efficient. 100KB is a lot of text, and frankly, HTML is redundant. Every And what’s the plan when a file’s too big? Zip it! If we could send a .zip file to the browser (index.html.zip) instead of plain old index.html, we’d save on bandwidth and download time. The browser could download the zipped file, extract it, and then show it to user, who’s in a good mood because the page loaded quickly. The browser-server conversation might look like this: 1. Browser: Hey, can I GET index.html? I’ll take a compressed version if you’ve got it. The formula is simple: Smaller file = faster download = happy user. Don’t believe me? The HTML portion of the yahoo home page goes from 101kb to 15kb after compression: The tricky part of this exchange is the browser and server knowing it’s ok to send a zipped file over. The agreement has two parts If the server doesn’t send the content-encoding response header, it means the file is not compressed (the default on many servers). The “Accept-encoding” header is just a request by the browser, not a demand. If the server doesn’t want to send back compressed content, the browser has to make do with the heavy regular version. The “good news” is that we can’t control the browser. It either sends the Our job is to configure the server so it returns zipped content if the browser can handle it, saving bandwidth for everyone (and giving us a happy user). For IIS, enable compression in the settings. In Apache, enabling output compression is fairly straightforward. Add the following to your .htaccess file: Apache actually has two compression options: Deflate is quick and works, so I use it; use mod_gzip if that floats your boat. In either case, Apache checks if the browser sent the “Accept-encoding” header and returns the compressed or regular version of the file. However, some older browsers may have trouble (more below) and there are special directives you can add to correct this. If you can’t change your .htaccess file, you can use PHP to return compressed content. Give your HTML file a .php extension and add this code to the top: We check the “Accept-encoding” header and return a gzipped version of the file (otherwise the regular version). This is almost like building your own webserver (what fun!). But really, try to use Apache to compress your output if you can help it. You don’t want to monkey with your files. Once you’ve configured your server, check to make sure you’re actually serving up compressed content. Be prepared to marvel at the results. The instacalc homepage shrunk from 36k to 10k, a 75% reduction in size. I’ve set up some pages and a downloadable example: Feel free to download the files, put them on your server and tweak the settings. As exciting as it may appear, HTTP Compression isn’t all fun and games. Here’s what to watch out for: Enabling compression is one of the fastest ways to improve your site’s performance. Go forth, set it up, and let your users enjoy the benefits.Wait, wait, wait: Why are we doing this?
http://www.yahoo.com/index.html
, your browser talks to a web server. The conversation goes a little like this:
2. Server: Ok, let me see if index.html is lying around…
3. Server: Found it! Here’s your response code (200 OK) and I’m sending the file.
4. Browser: 100KB? Ouch… waiting, waiting… ok, it’s loaded.So what’s the problem?
<html>, <table> and <div>
tag has a closing tag that’s almost the same. Words are repeated throughout the document. Any way you slice it, HTML (and its beefy cousin, XML) is not lean.
2. Server: Let me find the file… yep, it’s here. And you’ll take a compressed version? Awesome.
3. Server: Ok, I’ve found index.html (200 OK), am zipping it and sending it over.
4. Browser: Great! It’s only 10KB. I’ll unzip it and show the user.The (not so) hairy details
Accept-Encoding: gzip, deflate
Content-Encoding: gzip
Setting up the server
Accept-encoding: gzip, deflate
header or it doesn’t.
# compress text, html, javascript, css, xml:
AddOutputFilterByType DEFLATE text/plain
AddOutputFilterByType DEFLATE text/html
AddOutputFilterByType DEFLATE text/xml
AddOutputFilterByType DEFLATE text/css
AddOutputFilterByType DEFLATE application/xml
AddOutputFilterByType DEFLATE application/xhtml+xml
AddOutputFilterByType DEFLATE application/rss+xml
AddOutputFilterByType DEFLATE application/javascript
AddOutputFilterByType DEFLATE application/x-javascript
# Or, compress certain file types by extension:
<Files *.html>
SetOutputFilter DEFLATE
</Files>
In PHP:
<?php if (substr_count($_SERVER['HTTP_ACCEPT_ENCODING'], 'gzip')) ob_start("ob_gzhandler"); else ob_start(); ?>
Verify Your Compression
Try Some Examples
Caveats
发表评论
-
js和css的合并
2012-02-03 14:23 1216互联网技术的发展,很多行业都在互联网开疆拓土;在一路攻城拔寨后 ... -
关键词分析方法TDK
2012-01-18 15:38 1436TDK是html 的规范,在w3c组织有说明。 搜索引擎爬虫在 ... -
SEO中的图片优化
2011-12-14 14:21 1074图片和视频等内容为早期互联网搜索引擎明确提出的不能抓取的资源, ... -
bing外链查询工具
2011-12-12 10:36 1737在最近一个月全面体验 ... -
页头/页脚的优化
2011-10-10 15:57 918对于网页来说,内容是非常重要的。网页内容在说什么只有阅读全文才 ... -
seo工作list
2011-10-09 17:02 930整理一下SEO要做的工作内容: 搜索引擎收录 --不同搜 ... -
新建网站SEO的checklist
2011-09-23 17:35 976一个新站点要检查的seo相关的清单: 1、可访问 网站的稳定性 ... -
长尾词优化的过程控制和方法
2011-09-21 10:44 1089我们都知道80/20法则,越 ... -
竞争对手研究-qunar.com 酒店业务URL结构
2011-08-11 11:21 1261SEO分析竞争对手:页面标题、关键词、页面关键词的分布、关键词 ... -
多个搜索引擎联合打造更丰富的网络
2011-08-05 22:22 1064由Google、Bing和雅虎共同发起的一个新项目,将为网页上 ... -
title和文本内容的seo要求
2011-07-29 11:03 934title信息 网页的title用于告诉用户和搜索引擎 ... -
SEO过程中Url友好建设的方法
2011-07-29 10:58 998什么是好的url? 创建具有良好描述性、规范、简单的url, ... -
短时间内提升SEO的表现方法
2011-06-22 10:01 814这几年的不断实践中试图去总结一些通用的方法可以帮助seor建立 ... -
搜索引擎优化工作内容
2011-06-16 13:36 831搜索引擎优化要做什么?一直没有梳理,原因:一、过于繁杂涉及到的 ... -
URL唯一的重要性
2011-06-13 09:59 1193最近一直遇到URL重复的问题,相信有很多大中型网站都会遇到。这 ... -
不带前缀www的域名转向到带www.域名的Apache 301转向配置样例
2011-05-04 11:34 2357最近一直有朋友问不带www的域名怎样跳转到带www的域名, ... -
SEO的定位
2011-04-21 16:57 825SEO是一种重要的营销方式,现在,过去搜索引擎的触角的似乎无法 ... -
细说Google Analytics中的流量来源
2011-03-17 10:36 1639这些天和BI同事梳理了网站的数据分析指标,构建了按照产品线和流 ... -
网站性能优化视频详解
2011-03-03 16:53 940网站性能优化的资料比较详细的,可以做为入门参考 网站优化 ... -
分页导航-网站分类属性
2011-03-02 10:50 964网站的内容丰富、分类 ...
相关推荐
High Performance iOS Apps Optimize Your Code for Better Apps 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源...
High Performance iOS Apps- Optimize Your Code for Better Apps 英文无水印pdf pdf所有页面使用FoxitReader和PDF-XChangeViewer测试都可以打开 本资源转载自网络,如有侵权,请联系上传者或csdn删除 本资源...
- **Page compression**:选择“Enabled”,这将启用Gzip压缩,减少页面传输大小。 4. **块缓存**: - **Block cache**:选择“Enabled”,这样可以将区块缓存起来,避免每次请求都需要重新加载。 5. **CSS...
C++ High Performance Boost and optimize the performance of your C++17 code_Code 源码 本资源转载自网络,如有侵权,请联系上传者或csdn删除 查看此书详细信息请在美国亚马逊官网搜索此书
### Qualcomm Hexagon SDK: 深入解析与多媒体优化 #### 一、Hexagon SDK简介 **Qualcomm Hexagon SDK** 是由Qualcomm Technologies, Inc.开发的一款强大的软件开发工具包,旨在帮助开发者轻松利用Hexagon数字信号...
If you’re an iOS developer with app-building experience, this practical guide provides tips and best practices to help you solve many common performance issues. You’ll learn how to design and ...
Getting Started with Varnish Cache: Accelerate Your Web Applications by Thijs Feryn English | 13 Mar. 2017 | ASIN: B06XP3D6Z2 | 253 Pages | AZW3 | 720.91 KB How long does it take for your website to ...
System Optimize Tools V1.0.1 System Optimize Tools V1.0.1 System Optimize Tools V1.0.1 System Optimize Tools V1.0.1 System Optimize Tools V1.0.1 System Optimize Tools V1.0.1 System Optimize Tools V...
"node-optimize"库的核心功能是代码合并与压缩。它能将多个JavaScript模块整合到一个文件中,这样浏览器只需要加载一个文件就能执行整个应用,大大减少了网络请求。此外,该库还会对合并后的代码进行压缩,去除不必...
Scikit-optimize,也称为skopt,是Python中一个用于高效优化算法的库,特别适合在高维度空间中进行参数调优。它基于Bayesian优化、随机森林和Gaussian过程等机器学习技术,为用户提供了一套简洁而强大的接口来解决...
`laravel-optimize-images`是一个针对Laravel 4的扩展,旨在帮助开发者更有效地管理和优化项目中的图片资源。这个扩展提供了命令行工具,使得批量处理和优化图像变得更加便捷。 在深入探讨`laravel-optimize-images...
for d1-7C1-6k1-3srcBoost Your Modem & Browser Speed up to 400% & Optimize your Internet Experience. Easy-to-use, Internet Optimizer for Windows 95, 98, ME, NT, 2000 and XP designed to automatically ...
Sams Teach Yourself HTML, CSS & JavaScript Web Publishing in One Hour a Day, Covers HTML5, CSS3, and jQuery 7th Series: Sams Teach Yourself Paperback: 768 pages ...Optimize your site for search engines
HTTP and TCP servers, optimize server responses with GZIP compression, and implement routing and logging in a Go web application. Chapter 2, Working with Templates, Static Files, and HTML Forms, ...
SSD Optimize v1.1 Build 823是一款专为固态硬盘(SSD)设计的优化软件,旨在最大化地提升SSD的性能和寿命。固态硬盘与传统的机械硬盘(HDD)在工作原理上有所不同,SSD没有机械部件,数据读取速度更快,但写入操作...
• Extend, accelerate, and optimize Spark routines with advanced API platform constructs, including shared variables, RDD storage, and partitioning • Efficiently integrate Spark with both SQL and ...
**Lzo压缩算法详解与VS2005实践** ...然而,LZO的压缩比通常低于其他更复杂的压缩算法,如DEFLATE(gzip/zlib所使用)或LZ4。因此,在考虑使用LZO时,应权衡速度、内存占用和压缩比之间的关系,以满足特定项目的需求。