如何deflate js文件在nginx? [英] how to deflate js file in nginX?

查看:256
本文介绍了如何deflate js文件在nginx?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在寻找如何压缩加载时间js文件,我尝试我的问题(我正在使用Extjs)。

I’m looking for "how to compress load time js file" and I try the solution of my question (I’m using Extjs).

我的朋友建议太。但是,它使用Apache作为Web服务器。任何人都知道如何做的技巧在NGINX?

My friend suggest this too. But, it use Apache as web server. Anybody know how to do the trick in NGINX??

我的托管使用nginx作为网络服务器,我不知道有关网络服务器配置的任何信息。

My hosting uses nginx as web server and i don’t know anything about web server configuration.

,如果我的英语不好..

sorry, if my english bad..

推荐答案

如果你不知道任何关于Web服务器配置,我假设你也不知道如何/在哪里编辑配置文件。

If you do not know anything about web server configuration, I am assuming you also do not know how/where to edit the config file.

nginx conf文件位于 /etc/nginx/nginx.conf (在Ubuntu 12.04中验证)

The nginx conf file is located at /etc/nginx/nginx.conf (verified in Ubuntu 12.04)

默认情况下,启用nginx gzip模块。因此,请检查此服务是否在未使用此类在线工具启用。

By default, nginx gzip module is enabled. So check from this service whether it is enabled on not using an online tool like this.

如果禁用,请在nginx.conf中的服务器{...}条目前添加此条目

If it is disabled, add this before server {...} entry in nginx.conf

# output compression saves bandwidth
gzip  on;
gzip_http_version 1.1;
gzip_vary on;
gzip_comp_level 6;
gzip_proxied any;
gzip_types text/plain text/html text/css application/json application/javascript application/x-javascript text/javascript text/xml application/xml application/rss+xml application/atom+xml application/rdf+xml;

# make sure gzip does not lose large gzipped js or css files
# see http://blog.leetsoft.com/2007/07/25/nginx-gzip-ssl.html
gzip_buffers 16 8k;

# Disable gzip for certain browsers.
gzip_disable "MSIE [1-6].(?!.*SV1)";

这篇关于如何deflate js文件在nginx?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆