Member
From: Loughborough, United Kingdom
Registered: 2006-04-14
Posts: 805
I've been thanked 13 times.
Offline
I'm trying to work out the best way for me to cache the pages on my site but my pages vary depending on the country the user is in, only by small values, a flag here, a phone number there, pricing info etc.
Only small values change but a user in the UK needs to see the UK version and there are 21 countries we change the output for so each needs to get their own version.
I can't just cache the site as it is now as the cache could then serve the wrong geo-specific content to the user.
What's best practice here?
I suppose I could create a clean, UK version of the page and use javascript client side to render the country specific bits inside the document object model.
Or I could create a different version of the cache for each country and serve those out.
Has anyone here introduced a cache system? If so how does the server cope with things before and after, I've seem 1 to 10 times faster and load cut right down mentioned elsewhere but wondered what people here got when they introduced a cache.
Also, are there any SEO implications to consider with having multiple versions of the same page. Would the dymanic client side version be best? Afterall I'm only proposing to use the DOM and innerhtml to change small values, not the actual page's 'content'.
21 different caches would mean a hell of a lot of writing to the server which is something I try to avoid as much as possible, the javascript solution would only work on scriptable browsers any non-scripted browser regardless of where they are in the world would see the UK pricing info with a noscript 'order from other countries' element as a fallback
If anyone can share thoughts I'd appreciate it. I'm just trying to get the logic of this right in my head before I start to spec it all up and bring it to life.
NoSting Hosting - Brightside Hosting Ltd: Member of Nominet / eNom ETP
^^^ Now with over 400 free templates, ShoutCast, LAME + FFMPeg
Ringtones - Palace Marketing Ltd: D2C and B2B mobile content since 2002
Member
From: York, England
Registered: 2005-11-04
Posts: 608
I've been thanked 11 times.
Offline
I use this for cacheing
http://www.phpclasses.org/browse/file/16052.html
It's rather good. I highly recommend it.
The geo specific thing could be got round with some if n elses i think.
dig this:
you have a my.cache.php class file for each specific area. lets say uk.cache.php, us.cache.php
you call each one in the same place with some ifs n elses
You'll have to change a few things in each file so it saves the cache with different names.
Oh hang on, maybe you could simply put the geo's in the class file, so it simply saves with a name depending on the geo.
Probably didnt make sense at all. go look at the class and see what you can come up with.
Member
From: Loughborough, United Kingdom
Registered: 2006-04-14
Posts: 805
I've been thanked 13 times.
Offline
Thanks for the link, it's more food for thought.
I'm not that keen really on the idea of making a cache of each page for each country, it is one option but would mean writing 21 files to the server when only the 1 is needed with the javascript solution.
I could apply an id to the country specific secions and propagate that with the UK data when the page is rendered and sent to the cache, inside this page there would then be a call for some javascript which reads the value of the country cookie we set before and updates the document inside the relevant ids with the geo specific data.
The cache system I've been looking at is over on I Love Jack Daniels - there's a point in the comments there that needs considering about creating temp files on the fly to stop a user from calling a cache'd page inbetween the server staring and finishing writing the contents of that file.
I've had a play around with a that caching script locally and it works a treat, I just want to get the logistics of a full deployment sorted.
When you say it's rather good and you recomend it can you quote any figures of performance increase on your box?
NoSting Hosting - Brightside Hosting Ltd: Member of Nominet / eNom ETP
^^^ Now with over 400 free templates, ShoutCast, LAME + FFMPeg
Ringtones - Palace Marketing Ltd: D2C and B2B mobile content since 2002
Moderator
From: Yorkshire, UK
Registered: 2006-08-19
Posts: 2860
I've been thanked 85 times.
Offline
I found somrthing called traslation gold - it used google to translate your page and then cached the result - it's the caching part that may be of interest here
the html output is saved in a file, the file name being an md5 hash of the date and timestamp
on a call to a page, the logic is something like this
if cached version exists
if cached version is in date
showe cached version
else
regen the page and cache with new timestamp
else
generate page and cache
Member
From: Loughborough, United Kingdom
Registered: 2006-04-14
Posts: 805
I've been thanked 13 times.
Offline
the logic and theory of applying a cache is easy enough.
i love jack daniels wrote:
1. Receive request for page
2. Check for the existence of a cached version of that page
3. Check the cached copy is still valid
* If it is, send the cached copy
* If not, create a new cached copy and send it
it was the rendering country specific bits on the fly while still keeping a cache that i was working on.
I've been mocking up the javascript solution so far using innerhtml to do the work for me......
Code: html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=windows-1250">
<title>Dynamic Cache Testing with PHP and JavaScript</title>
</head>
<body>
<h1 id="country">United Kingdom</h1>
<p>Text WOW 12345 to <span id="shortcode">88600</span>
<br />
Price: <span id="price">£1.50</span>
<br />
Networks supported: <span id="networks">O2 - Orange - Vodafone - Three - T-Mobile</span>
<br />
<br />
<span id="flag"><img src='http://www.web2txt.co.uk/flags/gb.png' alt='United Kingdom' width='25' height='16' /></span></p>
<noscript>
<p>To order in other countries please click here</p>
</noscript>
<script type="text/javascript" src="order-info.js">
</script>
</body>
</html>
It's an example, naturally I'd not be messing with H1 tag contents like this, nor would I even display anything like this in a H1 in the real world 
The javascript call at the footer of that document just sets the ID'd elements to have the correct local values for the user. The noscript will be there as a fallback for non scripted browsers.
Code: javascript
shortcode.innerHTML = "2098";
price.innerHTML = "30 NOK";
country.innerHTML = "Norge";
networks.innerHTML = "Telenor - Tele2 - Netcom";
flag.innerHTML = "<img src='http://www.web2txt.co.uk/flags/no.png' width='25' height='16' />";
I'll make a PHP script create the javascript based on cookie values we read or write before we make the page. That way I can tie in the 21 countries we want to target with numbers and prices then fallback on the UK for the ones we're not targetting.
At least no matter where Google or friends spider us from they will only ever see one consistent version of the page. Not several copies with tiny differences.
View it in a browser though and it will show the Norwegian order info. That's the desired result I want.
I know this is manipulating page content (for the benefit of the user) but could any engines consider it spoofing for us to update the page to the browser like this?
Hey, funky stuff is this is the same way I'd create a multivariant testing platform!
NoSting Hosting - Brightside Hosting Ltd: Member of Nominet / eNom ETP
^^^ Now with over 400 free templates, ShoutCast, LAME + FFMPeg
Ringtones - Palace Marketing Ltd: D2C and B2B mobile content since 2002
| Never |


