Welcome! Log In Create A New Profile

Advanced

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

agentzh
February 18, 2011 06:58AM
On Fri, Feb 18, 2011 at 7:19 PM, Alexander Kunz <akunz@ntmedia.de> wrote:
>
> Hello,
>
> that sound really interested. Please can you give me a hint how you use Lua
> as applicaton language? How do you merge for example a Headline from
> mysql/redis into your html code?

Our own applications are typical RIAs, that is, from the point of view
of MVC, the View and Controller are completely running on the client
side, i.e., in our user's web browser, kinda like Gmail :) We've been
using a pure-client-side templating system and compiler called
Jemplate [1].

The basic model looks like this:

1. nginx just serves static files like html, js, css, jpg for the web
app backbone that loads into the user's web browser and runs.

2. The client side JavaScript code issues (cross-site) AJAX requests
to our web service servers which also runs another set of nginx
instances which rely on ngx_drizzle, ngx_lua, and etc to efficiently
emit JSON formatted data.

3. The client side JS code put the data with the (compiled) templates
and get the final HTML fragments that are ready to be put into a node
in the HTML DOM (or XML for the flash components). Then the users see
page regions updated.

Maybe we can call it Service-Oriented Applications? Oh well...

And yeah, RIAs hate most search engine crawlers. Some of our module
users are combining ngx_lua with ngx_ctpp2 [2] for efficient server
side templating where ctpp2 [3] is a templating engine written in C++.
But I've never tried ngx_ctpp2 myself (yet) and I may roll out my own
implementation of a server-side template engine for Perl's TT2
templating language in pure C some time in the future ;)

> Is it possible to use something like
> templates? Or replace a token like ##Headline## in static html pages?
>

Sure, see above. Also, any templating engines for Lua can be used
directly. The basic steps are:

local data = get_data_from_remote()
local html = generate_html_from_template("/path/to/my/template")
ngx.print(html) -- emit it!

> With content_by_lua i can wonderful output the data, but what about the html
> code?
>

Why can't you just regard HTML as a special form of "data"? ;)

Cheers,
-agentzh

[1] http://search.cpan.org/perldoc?Jemplate
[2] svn://vbart.ru/ngx_ctpp2
[3] http://en.wikipedia.org/wiki/CTPP

_______________________________________________
nginx mailing list
nginx@nginx.org
http://nginx.org/mailman/listinfo/nginx
Subject Author Posted

How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

agentzh February 14, 2011 12:30AM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

António P. P. Almeida February 14, 2011 05:32PM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

Eugaia February 14, 2011 06:52PM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

Ryan Malayter February 15, 2011 02:04PM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

Dayo February 15, 2011 02:23PM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

Dayo February 15, 2011 02:27PM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

agentzh February 15, 2011 11:28PM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

Alexander Kunz February 18, 2011 06:22AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

agentzh February 18, 2011 06:58AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

agentzh February 18, 2011 06:58AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

Alexander Kunz February 18, 2011 07:34AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

Justin Cormack February 18, 2011 08:26AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

agentzh February 19, 2011 01:10AM

Re: How nginx's "location if" works (Was Re: Setting cache parameter via if directives)

Alexander Kunz February 19, 2011 05:46AM

Re: How nginx's "location if" works (Was Re: Setting cache parameters via if directives)

seekvn September 28, 2021 04:57AM



Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 70
Record Number of Users: 6 on February 13, 2018
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready