X-Cart: shopping cart software

X-Cart forums (https://forum.x-cart.com/index.php)
-   Dev Questions (https://forum.x-cart.com/forumdisplay.php?f=20)
-   -   Caching Trustlogo and other third-party js files (https://forum.x-cart.com/showthread.php?t=58144)

geckoday 02-20-2011 11:12 AM

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.

Jon 02-21-2011 07:02 AM

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.

bigredseo 02-21-2011 09:39 AM

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?

geckoday 02-22-2011 06:30 AM

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.

DogByteMan 06-18-2011 10:40 PM

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!


All times are GMT -8. The time now is 04:31 AM.

Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.