nginx gzip

55 views
Skip to first unread message

Liam McLennan

unread,
Apr 20, 2013, 8:30:01 PM4/20/13
to ged...@googlegroups.com
Has anyone been able to get nginx gzip compression working for a geddy site?

I have experimented with nginx configuration but have only been able to get gzip to work for css files. text/html and javascript files are not being compressed.


Matthew Eernisse

unread,
Apr 20, 2013, 8:39:08 PM4/20/13
to ged...@googlegroups.com
Shouldn't be any difference between CSS and (client-side) JS. That's really weird. Are you talking about static HTML or pages generated from rendered templates?


On Saturday, April 20, 2013, Liam McLennan wrote:
Has anyone been able to get nginx gzip compression working for a geddy site?

I have experimented with nginx configuration but have only been able to get gzip to work for css files. text/html and javascript files are not being compressed.


--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+u...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Liam McLennan

unread,
Apr 20, 2013, 9:25:25 PM4/20/13
to ged...@googlegroups.com

Rendered template. Ejs.

You received this message because you are subscribed to a topic in the Google Groups "GeddyJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geddyjs/kGiVpuNJL78/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to geddyjs+u...@googlegroups.com.

Liam McLennan

unread,
Apr 20, 2013, 9:26:31 PM4/20/13
to ged...@googlegroups.com

I'm running in development mode.need to try production to see if that helps.

On Apr 21, 2013 10:39 AM, "Matthew Eernisse" <m...@fleegix.org> wrote:
You received this message because you are subscribed to a topic in the Google Groups "GeddyJS" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/geddyjs/kGiVpuNJL78/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to geddyjs+u...@googlegroups.com.
Message has been deleted

Matthew Eernisse

unread,
Apr 21, 2013, 1:11:54 AM4/21/13
to ged...@googlegroups.com, li...@eclipsewebsolutions.com.au
Session-cookies will make rendered template-pages (i.e., anything Geddy dynamically builds) un-cacheable by Nginx.

If you don't need sessions, you can fix this easily by setting the 'sessions' value in your config (e.g., development.js) to null.

Nginx *should* be happily caching any static content you have (plain HTML files, images, CSS, JS) if you've got it configured correctly.

If you could paste your config in a Gist or whatever, possibly some folks from the list here could help.


M.


On Saturday, April 20, 2013 6:25:25 PM UTC-7, Liam McLennan wrote:

Rendered template. Ejs.

On Apr 21, 2013 10:39 AM, "Matthew Eernisse" <m...@fleegix.org> wrote:
Shouldn't be any difference between CSS and (client-side) JS. That's really weird. Are you talking about static HTML or pages generated from rendered templates?

On Saturday, April 20, 2013, Liam McLennan wrote:
Has anyone been able to get nginx gzip compression working for a geddy site?

I have experimented with nginx configuration but have only been able to get gzip to work for css files. text/html and javascript files are not being compressed.


--
The official community discussion group.
website: geddyjs.org, source: https://github.com/mde/geddy, group: https://groups.google.com/d/forum/geddyjs?hl=en
---
You received this message because you are subscribed to the Google Groups "GeddyJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email to geddyjs+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
 

Matthew Eernisse

unread,
Apr 21, 2013, 3:12:51 PM4/21/13
to ged...@googlegroups.com, li...@eclipsewebsolutions.com.au
First of all, I'm an idiot for having it in my head you were talking about caching here, not gzip.

Secondly, apparently mailing-lists are hard. I ended up replying directly to a few subsequent messages from GMail, so they ended up getting dropped from this thread.

Here's the upshot:

Then I checked, and gzip was not working at all with Nginx on my Ubuntu host. I could see "gzip on;" in the settings, and I didn't see the --without-http_gzip_module opt-out in the compile flags, so it should have been working, but no files were actually getting compressed.

It was, in fact, turned on, but by default it only compresses text/html, so I needed to uncomment the gzip_types line that adds all the other static content that I want. I have verified that when you serve the static assets directly with Nginx, both CSS and JS files are gzipped as expected. Here's a sample config for a site set up to serve a Geddy app: https://gist.github.com/mde/5430658

However, template pages (text/html) are still *not* being compressed with this setup. I'm guessing it has something to do with the proxying layer, or a bad content-type from Geddy. I'll have to dig some more to figure out what's going wrong.

In any case, serving static assets directly from Nginx is definitely the way to go. The static file-serving in Geddy is very old and crufty, and pretty stupid -- it's really just there to allow you to do development. It's not meant for prod use.

Liam McLennan

unread,
Apr 26, 2013, 12:07:04 AM4/26/13
to Matthew Eernisse, ged...@googlegroups.com
Thanks for supplying the config example. I merged it into mine and it made a huge difference. Not only am I now getting gzip for most content types I am also able to notice a substantial difference in page load time. Anecdotally, I'd say it has halved my page load time. Time to DOMContentLoaded is now a respectable 1.69s with a cold cache over adsl.


Reply all
Reply to author
Forward
0 new messages