Vesta Control Panel - Forum

Community Forum

Skip to content

Advanced search
  • Quick links
    • Main site
    • Github repo
    • Google Search
  • FAQ
  • Login
  • Register
  • Board index Main Section Web Server
  • Search

nginx wordpress js with gzip?

Questions regarding the Web Server
Apache + Nginx, Nginx + PHP5-FPM
Locked
  • Print view
Advanced search
21 posts
  • 1
  • 2
  • 3
  • Next
hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

nginx wordpress js with gzip?

Post by hcjsy » Tue Jun 07, 2016 3:58 pm

Hi,
Can someone explain to my why if I use gzipwtf.com gtmetrix.com or the google web one, that it comes back saying that JS files are not gziped on my website?

however if I run a curl command

Code: Select all

 curl -H "Accept-Encoding: gzip" -I http://wordpress.highlands.ac.uk/wp-includes/js/wp-embed.min.js
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 07 Jun 2016 15:36:12 GMT
Content-Type: application/javascript
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Connection: keep-alive
Keep-Alive: timeout=60
Vary: Accept-Encoding
ETag: W/"57569748-57b"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Content-Encoding: gzip
it says it is working for JS?
Top

SS88
Posts: 336
Joined: Thu Nov 19, 2015 12:40 pm

Re: nginx wordpress js with gzip?

Post by SS88 » Tue Jun 07, 2016 4:15 pm

hcjsy wrote:Hi,
Can someone explain to my why if I use gzipwtf.com gtmetrix.com or the google web one, that it comes back saying that JS files are not gziped on my website?

however if I run a curl command

Code: Select all

 curl -H "Accept-Encoding: gzip" -I http://wordpress.highlands.ac.uk/wp-includes/js/wp-embed.min.js
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 07 Jun 2016 15:36:12 GMT
Content-Type: application/javascript
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Connection: keep-alive
Keep-Alive: timeout=60
Vary: Accept-Encoding
ETag: W/"57569748-57b"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Content-Encoding: gzip
it says it is working for JS?
What's your configuration like because none of your .JS files are gzipped (or so it says).
Top

hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

Re: nginx wordpress js with gzip?

Post by hcjsy » Wed Jun 08, 2016 7:03 am

gzip bit from : /etc/nginx/nginx.conf

Code: Select all

    # Compression
    gzip                on;
    gzip_comp_level     9;
    gzip_min_length     512;
    gzip_buffers        8 64k;
    gzip_types          gzip_types text/plain text/css application/json application/javascript text/xml application/xml
                        application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf
                        font/opentype image/svg+xml image/x-icon;
    gzip_vary           on;
    gzip_disable        "MSIE [1-6]\.(?!.*SV1)";
    gzip_proxied        any;


Top

SS88
Posts: 336
Joined: Thu Nov 19, 2015 12:40 pm

Re: nginx wordpress js with gzip?

Post by SS88 » Wed Jun 08, 2016 11:54 am

Was it a copy / paste job?

Please see bolded error:

gzip_types gzip_types text/plain text/css application/json application/javascript text/xml application/xml
application/xml+rss text/javascript application/vnd.ms-fontobject application/x-font-ttf
font/opentype image/svg+xml image/x-icon;

You may also want to add in application/x-javascript
Top

hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

Re: nginx wordpress js with gzip?

Post by hcjsy » Wed Jun 08, 2016 11:59 am

apologies the config doesnt have the duplicate gzip_types, I will add application/x-javascript , but that isn't in the mime types file so not sure it will do anything?
Last edited by hcjsy on Wed Jun 08, 2016 12:04 pm, edited 2 times in total.
Top

hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

Re: nginx wordpress js with gzip?

Post by hcjsy » Wed Jun 08, 2016 12:00 pm

Also the website is using web template hosting and proxy template hosting
Top

SS88
Posts: 336
Joined: Thu Nov 19, 2015 12:40 pm

Re: nginx wordpress js with gzip?

Post by SS88 » Wed Jun 08, 2016 12:04 pm

application/javascript is the "standard" and both others are obsolete but if you can add both to the mime types and test again it may help.

Also take a look in /home/<USER>/conf/web for nginx.conf files as a setting may be overriding it (no need to unless you have changed something in there) as the default proxy template is OK.
Top

hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

Re: nginx wordpress js with gzip?

Post by hcjsy » Wed Jun 08, 2016 12:05 pm

I've just ran the test again and still coming back with saying gzip not for js :(
Top

SS88
Posts: 336
Joined: Thu Nov 19, 2015 12:40 pm

Re: nginx wordpress js with gzip?

Post by SS88 » Wed Jun 08, 2016 12:11 pm

If you add it directly in server { }

/home/<USER>/conf/web/nginx.conf like so:

Code: Select all

server {

listen      blah;
server_name blah;
root        /home/blah/web/blah/public_html

gzip on;
gzip_disable "msie6";

gzip_comp_level 6;
gzip_min_length 1100;
gzip_buffers 16 8k;
gzip_proxied any;
gzip_types text/js text/javascript application/javascript application/x-javascript;
}
Does that work!?
Top

hcjsy
Posts: 16
Joined: Tue Jun 07, 2016 3:56 pm

Re: nginx wordpress js with gzip?

Post by hcjsy » Wed Jun 08, 2016 12:11 pm

Thanks for the suggestions.
SS88 wrote:application/javascript is the "standard" and both others are obsolete but if you can add both to the mime types and test again it may help.
nginx: [warn] duplicate extension "js", content type: "application/x-javascript", previous content type: "application/javascript" in /etc/nginx/mime.types:9
nginx: [warn] duplicate extension "js", content type: "application/x-javascript", previous content type: "application/javascript" in /etc/nginx/mime.types:9

but still the same :(
SS88 wrote:Also take a look in /home/<USER>/conf/web for nginx.conf files as a setting may be overriding it (no need to unless you have changed something in there) as the default proxy template is OK.
have checked these, but no reference to gzip in them.
Top


Locked
  • Print view

21 posts
  • 1
  • 2
  • 3
  • Next

Return to “Web Server”



  • Board index
  • All times are UTC
  • Delete all board cookies
  • The team
Powered by phpBB® Forum Software © phpBB Limited
*Original Author: Brad Veryard
*Updated to 3.2 by MannixMD
 

 

Login  •  Register

I forgot my password