Follow us on Twitter X-Cart on Facebook Wiki
Shopping cart software Solutions for online shops and malls
 

Caching Trustlogo and other third-party js files

 
Reply
   X-Cart forums > X-Cart 4 > Dev Questions
 
Thread Tools Search this Thread
  #1  
Old 02-20-2011, 11:12 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Caching Trustlogo and other third-party js files

A couple of days ago my site wasn't loading due to the Addthis server not responding when my pages were trying to load the Addthis javascript file. This has also happened in the past with the Comodo trustlogo. It really sucks when this happens as you have no control over the other server and you need to hack your site real quick to get the references off your site to get it up and running - once you notice it.

Well, the solution is really pretty simple. Copy the javascript files to your server and load them from there. Doh! Why didn't I do this years ago? But you want to be sure you load the latest version of the javascript file. So setup a cron job to recopy the files every night. Simple and effective.

To do this first add a directory called "cache" in your xcart directory where you will store copies of the js files on your server.

For a Comodo trustlogo you will have something like this in one of your templates:
Code:
<script language="JavaScript" src="https://secure.comodo.net/trustlogo/javascript/trustlogo.js" type="text/javascript"></script>

Before you change this go to your web hosting control panel and setup a cron job to copy the trustlogo.js file to your cache folder once a day using this command:
Code:
wget https://secure.comodo.net/trustlogo/javascript/trustlogo.js -O $HOME/www/cache/trustlogo.js
This command is for typical cpanel hosting with xcart installed in the root of your domain. You might need to adjust the $HOME/www/cache/trustlogo.js depending on what control panel you use, your server configuration and where you have installed xcart. Initially setup the cron to run once a minute until it runs the first time and you have verified that the js file was copied into the cache folder and looks good. Then change the schedule to run once a day.

Now go ahead and change the <script> tag in your template to:
Code:
<script language="JavaScript" src="{$current_location}/cache/trustlogo.js" type="text/javascript"></script>

No more hangs if the Comodo server isn't responding.

I did the same thing for my Hackerproof logo javascript and my Addthis javascript. Now no more scrambling to figure out why my site's not loading and scrambling to rip out a logo or Addthis.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote

The following user thanks geckoday for this useful post:
gb2world (04-14-2011)
  #2  
Old 02-21-2011, 07:02 AM
  Jon's Avatar 
Jon Jon is offline
 

X-Guru
  
Join Date: Oct 2002
Location: Vancouver, Canada
Posts: 4,200
 

Default Re: Caching Trustlogo and other third-party js files

Always a great idea. Lots of third party companies don't minimize or compress their js either, so you could do that to make your site load even faster. Additionally, the js could be loaded from a CDN.
Reply With Quote
  #3  
Old 02-21-2011, 09:39 AM
  bigredseo's Avatar 
bigredseo bigredseo is offline
 

X-Man
  
Join Date: Oct 2002
Location: Omaha, NE, USA
Posts: 2,364
 

Default Re: Caching Trustlogo and other third-party js files

That's great Ralph. Wish we had this before all the problems with Comodo last year

Any idea if this works (or variations) for GoDaddy's Site Seal and McAfee's Site Seals?
__________________
Conor Treacy - Big Red SEO - @bigredseo
Search Engine Optimization & Internet Marketing - We Bring Your Website Out Of Hiding!
If you can't be found on Google, Bing or Yahoo, you pretty much don't exist on the Internet.
Omaha SEO Office with National & Local SEO Services
Hourly Consulting - great for SEO Disaster Recovery, Audits and DIY Guidance
Reply With Quote
  #4  
Old 02-22-2011, 06:30 AM
 
geckoday geckoday is offline
 

X-Wizard
  
Join Date: Aug 2005
Posts: 1,073
 

Default Re: Caching Trustlogo and other third-party js files

Yeah, it seems to be an annual thing with Comodo and usually when I'm too busy to do anything but rip the seal off the site. Wish I'd thought of it sooner.

I'm not real familiar with the other seals but I don't see any reason it wouldn't work wherever they load a js file.
__________________
Manuka Bay Company
X-Cart Version 4.0.19 [Linux]

UGG Boots and other fine sheepskin products
http://www.snowriver.com
Reply With Quote
  #5  
Old 06-18-2011, 10:40 PM
  DogByteMan's Avatar 
DogByteMan DogByteMan is offline
 

X-Adept
  
Join Date: Mar 2003
Posts: 833
 

Default Re: Caching Trustlogo and other third-party js files

Anybody get this to work with the Comodo corner of trust.
If you try this with McAfee Secure you get a blank image for the get. Darn it!
__________________
Dedicated Server provided by EWD Hosting
X-Cart version 4.1.12
PHP 5.3.2
MySQL server 5.0.87-community
Operation system Linux
Perl 5.008008
dogbytecomputer.com
Reply With Quote
Reply
   X-Cart forums > X-Cart 4 > Dev Questions



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump


All times are GMT -8. The time now is 07:00 AM.

   

 
X-Cart forums © 2001-2020