Michel
Michel

Reputation: 23645

Question about Page Output Caching in ASP.NET

I wanted to use this statement

<%@ OutputCache Duration="20" Location="Any" VaryByParam="none"%>

for our homepage. (this works by the way)

But there are multiple domains pointing to the same site, like mydomain.fr and mydomain.ch.

Then, in the basepage i set the culture of the site to fr-FR if they typed mydomain.fr, de-CH when they typed mydomain.ch etc.

I was wondering, as both url's would load the same page /default.aspx, is the page served the same for both users (so when .fr comes first, the .ch visitor sees the (cached) .fr page), or does the framework think and say: hey, mydomain.fr/default.aspx is not the same as mydomain.ch/default.aspx, even if it's the same fysical page, so let's NOT take the cached one and recreate (and cache) a new version?

I've read about varybyheader for the page output caching, but .fr vs .ch is not a header i think?

Upvotes: 0

Views: 308

Answers (2)

ChrisLively
ChrisLively

Reputation: 88092

I would highly suggest that you don't automatically set the culture based on the domain they used to get to your site.

Instead, just respect the culture settings of the browser. One reason is that they could very well be going to your French site, but prefer things in English. The various versions of the browsers will have sent you their chosen culture settings.

Also, offer the users a little language icon (usually a flag) at the top of your site. This should allow them to change their language of choice.

As to your actual question: if you are implementing culture resources properly then you don't have to worry about caching. It's taken care of for you.

Upvotes: 0

Andrew Barber
Andrew Barber

Reputation: 40160

You could vary it by the HOST header, which would mean that each domain would have its own cache set.

The HOST header contains the hostname/domain name that the browser loaded; So, mydomain.fr or mydomain.ch, etc.

Upvotes: 2

Related Questions