Opened 10 years ago

Closed 10 years ago

#1995 closed defect (fixed)

[PATCH] Railsport's map key lingers in browser cache across language changes

Reported by: avar Owned by: Tom Hughes
Priority: major Milestone:
Component: website Version:
Keywords: i18n, rails Cc:

Description

Steps to reproduce:

  • View the map key in language blargh
  • Switch a language
  • View it again in language blurgh

Your map key will still be in language blargh when you want blurgh.

Attachments (1)

map-key-smash-cache.patch (647 bytes) - added by avar 10 years ago.
Smash the browser cache with a locale= URI parameter

Download all attachments as: .zip

Change History (6)

comment:1 Changed 10 years ago by Tom Hughes

Does the browser not pay attention to the Content-Language we send? Maybe we need to send a Vary header as well?

comment:2 in reply to:  1 Changed 10 years ago by avar

Replying to tom@compton.nu:

Does the browser not pay attention to the Content-Language we send? Maybe we need to send a Vary header as well?

The browser won't pay attention to it when you're sending an explicit Cache-Control header, which according to the RFC MUST be obeyed and overrides all other caching algorithms.

Besides, I don't think any browser will invalidate a cache on the basis that it's suddenly getting a lot of other objects in a different content language from a given website than it was getting them in previously. And on the basis of that invalidate all other objects that it's still caching that used the old content language. That's a very fuzzy caching strategy.

You're also sending a header indicating that the object is "public". So unless the URI indicates the language in some way two users using different languages but the same proxy might get mixed language content.

The best solution to this IMO is to just add locale=#{I18n.locale} to the query string. That way we can still cache the content publicly. Patch attached.

Changed 10 years ago by avar

Attachment: map-key-smash-cache.patch added

Smash the browser cache with a locale= URI parameter

comment:3 Changed 10 years ago by avar

Summary: Railsport's map key lingers in browser cache across language changes[PATCH] Railsport's map key lingers in browser cache across language changes

comment:4 Changed 10 years ago by Tom Hughes

The fact that we're marking it cacheable shouldn't matter - the question is not whether it is cached but whether the cached copy matches a subsequent request when accept-language has changed.

The whole point of content-language and vary is to tell caches what to use to key the cache so the cache can contain multiple copies of the same resource when that resource varies on the specified header and return the one that matches the current request.

comment:5 Changed 10 years ago by tomhughes

Resolution: fixed
Status: newclosed

(In [16880]) Send an appropriate Vary header when we negotiate the language to stop caches doing the wrong thing. Closes #1995.

Note: See TracTickets for help on using tickets.