I'm using nginx with Rails' page caching to serve static files. In order to take advantage of static files plus being able to serve dynamic content, I'm using SSI to make nginx pull dynamic "partials" out of Rails and put them in the cached pages.
I want to use memcached to store Rails'
authenticity_token, and then make nginx put it in static pages through the use of the session and nginx' memcache module.
/ssi/csrf_token returns the token for the current session, and it will also store the value in memcached using the key
Rails will send a cookie header like so:
I need to let the
HttpMemcachedModule retrieve the value for key
/ssi/csrf_token?session_id=..., so I have to rewrite the URI
/ssi/csrf_token to include the session id from the cookie. How would I go about this?
Let me try to explain this with an example so hopefully it's a bit more clear.
Say the static HTML page has the following code:
<meta name="csrf-token" content="<!--# include virtual="/ssi/csrf_token" -->"/>
So I guess the only thing I need is a rewrite rule that will turn
/ssi/csrf_token?session_id=41ded65..., so the memcached module will try to retrieve the proper key, and if it's not found it will go to Rails to get it.
I hope this isn't too contrived :)