I thought I’d share a quick and simple method to improving loading times when extracting JSON data from an API within a Magento build.
For one particular client, this improved loading times considerably and in some cases by over two seconds.
$cache_key = 'json_feed_name';
$cache_tag = 'homepage';
if ( false !== ($list = Mage::app()->getCache()->load($cache_key)) ) {
$list = unserialize($list);
} else {
$json = file_get_contents($_SERVER['HTTP_X_FORWARDED_PROTO'].'://'.$_SERVER['HTTP_HOST'].'/api/?json=get_content_feed');
$list = json_decode($json);
Mage::app()->getCache()->save(serialize($list), $cache_key, array($cache_tag), 3600*6);
}
Please note, I’ve used $_SERVER['HTTP_X_FORWARDED_PROTO']
to get the protocol used by CloudFlare as the service we’re contacting uses their service.
Webmentions
does celebrex work
does celebrex work
bupropion long term side effects
bupropion long term side effects
celecoxib classification
celecoxib classification
how long does it take for baclofen to work
how long does it take for baclofen to work
what is aripiprazole used for
what is aripiprazole used for
effexor sexual side effects
effexor sexual side effects
hormonio ddavp
hormonio ddavp
cozaar price at walmart
cozaar price at walmart
citalopram dosage 10 mg
citalopram dosage 10 mg
does flexeril show up on drug tests
does flexeril show up on drug tests
whats cephalexin used for
whats cephalexin used for
what is the half life of cymbalta
what is the half life of cymbalta
can you take amoxicillin with ibuprofen
can you take amoxicillin with ibuprofen
escitalopram coupon tennessee
escitalopram coupon tennessee
duloxetine 20mg capsules
duloxetine 20mg capsules
keflex while breastfeeding
keflex while breastfeeding
pdr metronidazole
pdr metronidazole
rybelsus commercial
rybelsus commercial
rybelsus titration
rybelsus titration
semaglutide 4 week results
semaglutide 4 week results
lasix 3169
lasix 3169
lisinopril schuppenflechte
lisinopril schuppenflechte
einnahmeschema metformin
einnahmeschema metformin
valacyclovir creatinine
valacyclovir creatinine
does lyrica thin your blood
does lyrica thin your blood
sulfamethoxazole tmp sleep aids
sulfamethoxazole tmp sleep aids
metronidazole flagystatin
metronidazole flagystatin
neurontin odpłatność
neurontin odpłatność
cialis dosage 20mg
cialis dosage 20mg
cialis for daily use
cialis for daily use
buy online viagra in usa
buy online viagra in usa
how to order vigra on internet
how to order vigra on internet
vancouver pharmacy viagra
vancouver pharmacy viagra
buy tadalafil online no prescription
buy tadalafil online no prescription
albany college of pharmacy
albany college of pharmacy
buy tadalafil cheap
buy tadalafil cheap
blood pressure on cialis
blood pressure on cialis