Hacker News new | past | comments | ask | show | jobs | submit login

This is a question that interests me as a Varnish user with a several-hundred-line VCL. We exclude certain URLs from caching altogether, drop certain cookies but not others, drop certain querystring params but not others, cache separate versions of the same page for mobile and non-mobile browsers, do limited caching behind basic auth, purge certain pages from cache when a post gets published, etc. VCL isn't the most elegant thing there is, but there's usually a way to do whatever I need. I don't know that Nginx isn't capable of just as much flexibility, but all the HOWTOs I've found are pretty simplistic and I haven't found the docs to be that helpful. If anybody has resources or experience to share regarding complex Nginx caching setups, I'd love to know about it.



I haven't used nginx caching in depth, but I can make a more general point about nginx scripting: It sucks. Hard.

You can get fancy[1] by writing your own modules or by building on top of helpers like ngx_devel_kit, but it gets messy very quick.

Implementing complex rules inside the config file is possible to a degree - but an utter nightmare. The syntax is extremely limited and the semantics are hard to predict (order of execution).

So, what nginx is lacking is a proper scripting interface with full control over the request pipeline. ngx_lua and ngx_v8 are in the works but not production-ready, yet.

Personally I'd go as far and say the entire config file should simply be ripped out and replaced with a scripting language.

[1] http://agentzh.org/misc/slides/nginx-conf-scripting/nginx-co... (press cursor right to walk through slides)





Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: