Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable gzip compression and browser caching of resources #890

Open
mfairchild365 opened this issue May 11, 2015 · 20 comments
Open

Enable gzip compression and browser caching of resources #890

mfairchild365 opened this issue May 11, 2015 · 20 comments

Comments

@mfairchild365
Copy link
Contributor

see https://developers.google.com/speed/pagespeed/insights/?url=http%3A%2F%2Fwdn.unl.edu%2F&tab=mobile

This is currently an issue for many framework provided assets and should be fixed.

@mfairchild365
Copy link
Contributor Author

@tsteiner what would it take to get these issues addressed? It seems fairly easy, but I'm not sure how easy it would be with the current architecture.

@tsteiner
Copy link
Member

Silly nginx: when you turn on gzip, it only compresses text/html content. I've told it to compress everything now.

gzip_types *;

Applied on http://unlcms-dr.autosplit.its-sys.unl.edu/. If everything looks ok, I'll do an RFC and get it on production.

@mfairchild365
Copy link
Contributor Author

Sweet. Thank you @tsteiner

Do these changes also include browser caching of resources, or just gzip?

@tsteiner
Copy link
Member

How long do you want wdn files cached?

@mfairchild365
Copy link
Contributor Author

7 days? Do @ericras or @kabel have any thoughts?

@saltybeagle
Copy link
Contributor

Would it be possible to coincide the cache expiration with a regular release timeline or RFC process?

@kabel
Copy link

kabel commented May 21, 2015

I like @saltybeagle's idea, but I don't know if it is practical in a server configuration. Optimally, 1M (month) would provide long life, but cache busting is probably always going to be an issue until we version our file names better.

@kabel
Copy link

kabel commented May 21, 2015

The HTML5 Boilerplate comes with a wealth of good server configuration options.

@mfairchild365
Copy link
Contributor Author

@kabel are you suggesting not caching until we resolve the issue or only caching for a short time (~1 day)?

@kabel
Copy link

kabel commented May 21, 2015

No, I would think that one month (our release cycle) is just fine.

@tsteiner
Copy link
Member

Is that your final answer?

@kabel
Copy link

kabel commented May 21, 2015

Yes, good enough.

We've gotta start somewhere and I don't know enough about the varnish/nginx combo to know if we're shooting ourselves in the foot when it comes to cache busting.

@tsteiner
Copy link
Member

Config updated on http://unlcms-dr.autosplit.its-sys.unl.edu/ . Let me know if/when to set up an RFC to push to production.

@mfairchild365
Copy link
Contributor Author

This appears to be working for me using curl, but not when changing my /etc/hosts file. I tested in two ways:

1: using curl:

curl -IH 'Host: www.unl.edu' -H 'Accept-Encoding: gzip' http://unlcms-dr.autosplit.its-sys.unl.edu/wdn/templates_4.0/css/all.css?dep=4.0.27
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 26 May 2015 14:14:13 GMT
Content-Type: text/css
Last-Modified: Tue, 26 May 2015 07:30:33 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Cache-Control: public, max-age=2592000
Content-Encoding: gzip
X-Cacheable: Yes
X-Varnish: 426163 360495
Age: 267
Via: 1.1 varnish-v4
Content-Length: 49561
Connection: keep-alive

2: changing my /etc/hosts file. This didn't result in assets being gziped or cached when viewing in a browser. Any idea why?

This is what I added to my hosts file

23.253.150.112 www.unl.edu
23.253.150.112 unlcms.unl.edu

@tsteiner
Copy link
Member

I'm not sure. I made the same changes to my hosts file and everything worked as expected:

curl -I --compressed http://unlcms.unl.edu/wdn/templates_4.0/css/all.css?dep=4.0.27
HTTP/1.1 200 OK
Server: nginx
Date: Tue, 26 May 2015 14:30:34 GMT
Content-Type: text/css
Last-Modified: Tue, 26 May 2015 07:30:33 GMT
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: GET
Cache-Control: public, max-age=2592000
Content-Encoding: gzip
X-Cacheable: Yes
X-Varnish: 557109
Age: 0
Via: 1.1 varnish-v4
Connection: keep-alive

@kabel
Copy link

kabel commented May 26, 2015

Works for me too, albeit, not with the IPs you had in your host file as those appear to be the production IPs.

@tsteiner
Copy link
Member

host 23.253.150.112
112.150.253.23.in-addr.arpa domain name pointer unlcms-dr-web-node-alpha.iad.rackspace.its-sys.unl.edu.

Looks like a DR server to me

@kabel
Copy link

kabel commented May 26, 2015

Ah, good point, read right over those extra letters. 👊

@mfairchild365
Copy link
Contributor Author

I blame my browser, it appears to be working now.

However, I did notice that curl -I --compressed http://www.unl.edu/splash/ isn't being gzipped, but curl -I --compressed http://unlcms.unl.edu/ is.

@tsteiner
Copy link
Member

Varnish is now setup to compress any uncompressed content of MIME type text/* (on the DR servers)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants