In Rails 4, how to achieve Edge Side Include and HTTP Cache Reverse Proxy behavior?


#1

I’m from Symfony2 PHP and currently migrating to Rails 4, I have no
knowledge with Rails 3 and before. I’m working on my web project with
one
last todo list to enable dynamic caching in this rails 4. In Symfony2
there are built in function to setup Edge Side Include behavior
effortless. Some of this functionality :

  • Sf2 have templating function to insert esi include tag <esi:include
    src=“http://…” /> with router name as parameter

http://symfony.com/doc/current/book/http_cache.html#using-edge-side-includes

{{ render_esi(url(‘latest_news’, { ‘max’: 5 })) }}

  • Sf2 have built in reverse proxy gateway to merge cached page which
    have esi tag with corresponding response from each included esi tag
    url.

http://symfony.com/doc/current/book/http_cache.html#edge-side-includes

Symfony2 comes with a reverse proxy (also called a gateway cache) written
in PHP. Enable it and cacheable responses from your application will start
to be cached right away. Installing it is just as easy. Each new Symfony2
application comes with a pre-configured caching kernel (AppCache) that
wraps the default one (AppKernel). The caching Kernel is the reverse proxy.

I have learning page, action, fragment cache. I also found Rack::ESI.
I
know there are middleware idiom, but I don’t know what it’s. I still
have
no idea how to setup all this info correctly. My esi tag doesn’t
replaced
with corresponding response from esi tag url like in Sf2. I think this
is
because I haven’t configured reverse proxy middleware in my Rails. So my
question is, in Rails 4, how to achieve Edge Side Include and HTTP Cache
Reverse Proxy behavior ?

Regards.


#2

On Thursday, April 3, 2014 2:36:32 AM UTC-4, Ardian Yuli Setyanto wrote:

Symfony2 comes with a reverse proxy (also called a gateway cache) written
this is because I haven’t configured reverse proxy middleware in my Rails.
So my question is, in Rails 4, how to achieve Edge Side Include and HTTP
Cache Reverse Proxy behavior ?

Regards.

Generally, ESI isn’t used in Rails since the inclusion of Russian Doll
caching which is generally more effective (at least I haven’t seen it
much,
maybe it is). You can use ESI using the middleware you’ve already
found,
but I believe you have to establish your own gateway-cache using
Mongrel-ESI or Varnish. I’m not positive on this, but you would have to
research it.

Personally, I would look at Russion Doll caching. Also, if your
application does a lot of authentication/authorization, I would look at
low
level caching as caching the user table can really speed things up in
applications that are authentication/authorization intensive.

@mike2r