Welcome to the MetaMod and Chameleon Support Forums.

Before posting, please check out the FAQs.

helpme

 

Need extra help with your Joomla site? Consider paid Joomla support by the developer of Chameleon and MetaMod.

 

Saving processing power by setting cookie

Saving processing power by setting cookie

I wanted to know how to set a users country as cookie the first time he requests a page and later showing modules based on checking the cookie.
To explain it better to you I have put a syntax.

check if a country name cookie is saved.(say user is from india)
if(cookie named india exists)
  {
   display appropriate module
  }
  else
  {
   check the maxmind database.
   Set the cookie Like cookie name india if it is india.
   Show the right module.
  }

I do not know php, please tell me the syntax for this.
I feel this will save some cpu power(Help me in optimizing my site)

Also will checking cookie on a browser take lot of time?

Please be free to tell me if this doesn't save anything much.
Thanking you,
George

Edited By: mof989
05-Jun-11 01:24:46

mof989
Beginner Modder
ranks
useravatar
Offline
1 Posts
Administrator has disabled public posting

Re: Saving processing power by setting cookie

Hi George,

all of these operations are very quick - I wouldn't worry about server load unless you're running a very high traffic site. In that case you might want to do profiling on the whole of your Joomla site to identify bottlenecks. In particular, you should be looking at full page caching based on GeoIP as this would give the maximum benefits to CPU utilisation.

To get some idea of the "cost" of GeoIP lookups, see here:

http://www.maxmind.com/app/benchmark

Using the pure PHP API, as done in MetaMod & MetaTemplate, is the slowest but does not require any additional server installations, apache recompiles etc.

On the test server used at MaxMind (Celeron 1.7 GHz machine with an IDE hard drive) they claim that the pure PHP API can do 875 lookups per second. That's about 1.1 milliseconds (0.0014s). I would argue that since this is only done maximum 1x per request, it's not a strong candidate for optimisation unless you are already doing heavy caching and have done significant database query optimision in Joomla.

Back to MetaMod again:

Whenever you turn on the GeoIP support in MetaMod, this lookup gets done on incoming requests. It doesn't get done in the "if" statement in the PHP code you enter into the box in MetaMod. Therefore the construct you are using above would not actually have any effect since the lookup get done every time anyway.

I'd be interested in knowing why you're looking at this particular optimisation: how heavy is your site traffic? What other optimisation steps have you taken?

Best regards,
Stephen

Stephen Brandon
MetaMod / Chameleon developer
If you use MetaMod or Chameleon, please post a rating and a review at the Joomla! Extensions Directory: Chameleon | MetaMod

metamodguy
useravatar
Offline
3328 Posts
User info in posts
Administrator has disabled public posting

Board Info

Board Stats:
 
Total Topics:
1679
Total Polls:
6
Total Posts:
5933
Total Posts Today:
2
User Info:
 
Total Users:
4371
Newest User:
kajha63871
Members Online:
0
Guests Online:
218

Online: 
There are no members online

Forum Legend:

 Topic
 New
 Locked
 Sticky
 Active
 New/Active
 New/Locked
 New Sticky
 Locked/Active
 Active/Sticky
 Sticky/Locked
 Sticky/Active/Locked