天天看點

上線部署那些事4

1、使用工具提高網站的通路體驗。

使用YSlow、pagespeed等工具找到網站的瓶頸,以及網站可以優化的地方,提高網站的通路效率和通路體驗。

2、開啟web伺服器的gzip壓縮,減少網絡流量。

web伺服器包括IIS,Apache,Nginx等。

應用伺服器包括tomcat等。

2.1開啟apache-windows的gzip

httpd官網文檔

<a href="http://httpd.apache.org/docs/2.2/mod/mod_deflate.html">http://httpd.apache.org/docs/2.2/mod/mod_deflate.html</a>

1

2

3

4

5

6

7

8

9

10

11

<code>1. httpd.conf中打開deflate_Module和headers_Module子產品</code>

<code>2. httpd.conf中添加:</code>

<code>&lt;</code><code>IfModule</code> <code>deflate_module&gt;</code>

<code>    </code><code>SetOutputFilter DEFLATE</code>

<code>    </code><code># Don’t compress images and other</code>

<code>    </code><code>SetEnvIfNoCase Request_URI .(?:gif|jpe?g|png)$ no-gzip dont-vary</code>

<code>    </code><code>SetEnvIfNoCase Request_URI .(?:exe|t?gz|zip|bz2|sit|rar)$ no-gzip dont-vary</code>

<code>    </code><code>SetEnvIfNoCase Request_URI .(?:pdf|doc)$ no-gzip dont-vary</code>

<code>    </code><code>AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css</code>

<code>    </code><code>AddOutputFilterByType DEFLATE application/x-javascript</code>

<code>&lt;/</code><code>IfModule</code><code>&gt;</code>

3、開啟浏覽器緩存,指定靜态資源的有效期。

3.1開啟apache-windows的靜态檔案浏覽器緩存

httpd官網文檔:

<a href="http://httpd.apache.org/docs/2.2/mod/mod_expires.html">http://httpd.apache.org/docs/2.2/mod/mod_expires.html</a>

12

13

14

15

16

<code>1、在apache的http.conf檔案中開啟expires_module子產品</code>

<code>2、添加下面的配置</code>

<code>&lt;</code><code>IfModule</code> <code>expires_module&gt;</code>

<code>    </code><code>ExpiresActive On</code>

<code>    </code><code>ExpiresByType image/gif "access plus 1 month"</code>

<code>    </code><code>ExpiresByType image/png "access plus 1 month"</code>

<code>    </code><code>ExpiresByType image/jpeg "access plus 1 month"</code>

<code>    </code><code>ExpiresByType image/x-icon "access plus 1 month"</code>

<code># expire stylesheets and javascript after 1 week in the website visitor cache</code>

<code>    </code><code>ExpiresByType text/css "access plus 1 week"</code>

<code>    </code><code>ExpiresByType application/javascript "access plus 1 week"</code>

<code>    </code><code>ExpiresByType text/javascript "access plus 1 week"</code>

<code># expire flash and XML 1 month and 1 week respectively in the website visitor cache</code>

<code>    </code><code>ExpiresByType application/x-shockwave-flash "access plus 1 month"</code>

<code>    </code><code>ExpiresByType text/xml "access plus 1 week"</code>

4、減少靜态資源的重複加載,例如image,js,css檔案。

将靜态資源單獨、統一管理。

單獨管理之後就可以實作将靜态資源交給web伺服器處理,應用伺服器隻處理動态的請求。

統一管理之後就可以減少靜态檔案的重複加載,對于相同的資源,都引用相同的位址,統一做管理和更新。

本文轉自 virusswb 51CTO部落格,原文連結:http://blog.51cto.com/virusswb/1224225,如需轉載請自行聯系原作者

繼續閱讀