Page 2 of 3

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:14 pm
by hcjsy
SS88 wrote: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!?
no didnt work either, and made sure I restarted the nginx service.

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:18 pm
by SS88
hcjsy wrote: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
mime.types should be added like so (example only):

Code: Select all

    image/jpeg                            jpeg jpg;
    application/javascript text/javascript application/x-javascript                js;
    application/atom+xml                  atom;
    application/rss+xml                   rss;
What is your OS? Windows?

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:21 pm
by SS88
One guy here? Maybe this would help?

http://stackoverflow.com/a/24529623/2669945

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:38 pm
by hcjsy
have adjusted the mime.types so that duplicate message is gone, and added the

Code: Select all

gzip_http_version   1.0;
thanks for finding that, but didnt work :(

the server is ubuntu 14

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:47 pm
by SS88

Code: Select all

root@pool:~# curl -H "Accept-Encoding: gzip" -I http://wordpress.highlands.ac.uk/wp-includes/js/wp-embed.min.js
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 1403
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Date: Wed, 08 Jun 2016 12:47:12 GMT
Content-Type: application/javascript
ETag: "57569748-57b"
Server: nginx
Accept-Ranges: bytes
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Vary: Accept-Encoding
Cache-Control: max-age=315360000
Not sending the header. I don't think I can help any further!

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 12:52 pm
by hcjsy
What do you mean by not sending the header?

I ran the command here and :

Code: Select all

root@oo:~# 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: Wed, 08 Jun 2016 12:50:48 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

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 1:04 pm
by SS88
I tried again on a different server:

Code: Select all

[root@atl ~]# curl -H "Accept-Encoding: gzip" -I http://wordpress.highlands.ac.uk/wp-includes/js/wp-embed.min.js
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 1403
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Date: Wed, 08 Jun 2016 13:03:32 GMT
Content-Type: application/javascript
ETag: "57569748-57b"
Server: nginx
Accept-Ranges: bytes
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Vary: Accept-Encoding
Cache-Control: max-age=315360000
and with --compressed

Code: Select all

[root@atl ~]# curl -H "Accept-Encoding: gzip" --compressed -I http://wordpress.highlands.ac.uk/wp-includes/js/wp-embed.min.js
HTTP/1.1 200 OK
Connection: Keep-Alive
Content-Length: 1403
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Date: Wed, 08 Jun 2016 13:04:04 GMT
Content-Type: application/javascript
ETag: "57569748-57b"
Server: nginx
Accept-Ranges: bytes
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Vary: Accept-Encoding
Cache-Control: max-age=315360000

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 1:14 pm
by hcjsy
strange, I just edited the config changed gzip to off, ran the curl on my machine again and came back as expected

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: Wed, 08 Jun 2016 13:10:48 GMT
Content-Type: application/javascript
Content-Length: 1403
Last-Modified: Tue, 07 Jun 2016 09:43:36 GMT
Connection: keep-alive
Keep-Alive: timeout=60
ETag: "57569748-57b"
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Cache-Control: max-age=315360000
Accept-Ranges: bytes
changed it back to on, and as expected at the bottom when running the command again:

Code: Select all

Content-Encoding: gzip

Re: nginx wordpress js with gzip?

Posted: Wed Jun 08, 2016 1:34 pm
by SS88
When I view it with Google Chrome css and js files are not sending the header either.
Request URL:http://wordpress.highlands.ac.uk/wp-con ... styles.css


HTTP/1.1 304 Not Modified
Connection: Keep-Alive
Expires: Thu, 31 Dec 2037 23:55:55 GMT
Date: Wed, 08 Jun 2016 13:32:39 GMT
ETag: "575696ed-69b"
Server: nginx
Last-Modified: Tue, 07 Jun 2016 09:42:05 GMT
Cache-Control: max-age=315360000

Re: nginx wordpress js with gzip?

Posted: Thu Jun 09, 2016 7:37 am
by hcjsy
I managed to resolve this. It was to do with the firewall (tmg 2010) not passing on from the client to the webserver that the client is gzip ready.