Serious problem: fragment caching with named route and multiple mongrels

Hi

I ran into what seemed to be a very serious problem with the way
caching works. However it seems so serious that I wonder if I'm
missing something very obvious !

Essentially if you use a filestore and a fragment cache with multiple
mongrels and named routes you get key names like :

/path/to/cache/128.0.0.1.8000/users/json
/path/to/cache/128.0.0.1.8001/users/json
/path/to/cache/128.0.0.1.8003/users/json

Notice that different mongrels get a different directory. This is
because fragment key is calculated with "url_for".

The problem with this is obvious, since the fragments are not
application wide and it depends which mongrel server the request is on
to which folder it will look in.

I managed to fix it by using a string rather than a named route, but
I'm still fairly confused. I wonder whether its a feature, but I can't
see what it would be useful for!

Jonah
*...(

I managed to fix it by using a string rather than a named route, but
I'm still fairly confused. I wonder whether its a feature, but I can't
see what it would be useful for!

For when the host includes scoping information, like:

/path/to/cache/david.highrisehq.com/users/json
/path/to/cache/jonah.highrisehq.com/users/json

The problem here seems to be that the reverse mapping is not setup
correctly, such that Rails thinks that the host is localhost, instead
of the external host. This will be a problem whenever url_for is used
to create complete URLs and not just paths.

yes that makes sense - in fact the full list of folders that were
being created were :

/127.0.0.1:8000/
/127.0.0.1:8001/
/64squar.es/
/blog.64squar.es/

which indicates it was working sometimes. However "blog.64squar.es" is
not being currently used but it does point to the same IP.

anything I can look at to try to track it down ? This is on 1.2.5 BTW

which indicates it was working sometimes. However "blog.64squar.es" is
not being currently used but it does point to the same IP.

anything I can look at to try to track it down ? This is on 1.2.5 BTW

You probably don't have an X-Forwarded-For header? Without that
request.host will default to localhost:port.

You'd have the same problem with generated urls from your application,
all those links will be pointing to http://127.0.0.1:3000/people etc

I dont have a problem with the generated urls. It's on a production
site with lots of users - so I'd have found out about those !

It's a standard deprec install on ubuntu with rails 1.2.5 and apache.
totally out of the box and vanilla .

Where would I set X-Forwarded-For header ?

Thanks

Jonah

I think Koz meant that url_for() helper would be having problems. If you’re just using path helpers (like person_path(@person)) or url_for with ‘:only_path => true’ then you may not be seeing the errors.

Try putting a link to url_for(:controller => ‘users’) on your production site and see what pops up.

The X-Forwarded-For header needs to be set by your world-facing server (e.g. Apache, Nginx).

Good luck!

::Jack Danger