# Caching + routing

**URL:** <https://www.ruby-forum.com/t/caching-routing/115805>\
**Category:** Rails\
**Created:** [September 28, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/caching-routing/115805 "2007-09-28T17:30:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [September 28, 2007, 5:30pm UTC](https://www.ruby-forum.com/t/caching-routing/115805/1 "2007-09-28T17:30:44Z")

</div>

Newby here!

I have an application that has pages that are translated. Clicking on  
flags changes the language. That is working nicely, but, for the  
‘guest’ area I would like to cache these pages as they never change.  
My problem is that the page has the same url for all the languages.  
I have an action that does this:  
def set\_lang  
set\_language(params[:language])  
redirect\_to(session[:current\_page])  
end

Then the page renders content based on the language set via  
set\_language.

By using routes is it possible to make the page cacher think the pages  
are different? Perhaps by appending the current language to the front  
of the url? (eg /en/controller/action). I am in over my head as far as  
routing and how to adequately do this.

What I was thinking was this:

- default route sends user to /language/guest/welcome
- set language redirects to /language/(current page)

Would this work, and if so, how on earth do I code it!

Sorry for the rambling email… any insight or solutions most most  
welcome!

Phil

---

<div class="post-metadata">

**Author:** ![phil](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/e95f7d/32.png) [@phil](https://www.ruby-forum.com/u/phil)\
**Post date:** [September 30, 2007, 3:21pm UTC](https://www.ruby-forum.com/t/caching-routing/115805/2 "2007-09-30T15:21:27Z")

</div>

Could I perhaps use url rewriting to put a subdomain on each language?

Help!
