Call (877) SITE-OPT (748-3678)

Code: Example RSS cache

Chapter 9 - Advanced Web Performance Optimization

To localize an external RSS feed, you can use a conversion script such as Jonathan Eisenzopf’s script to grab an RSS feed and convert it to HTML or text on your server.18 Once the feed is on your server, you can display it locally to avoid any off-site delays. The format for a cron job file is as follows:

[min] [hour] [day of month] [month] [day of week] [program to be run]
    field = allowed values
    min = 0-59
    hour = 0-23
    day of month = 1-31
    month = 1-12 (or names, see below)
    day of week = 0-7 (0 or 7 is Sun, or use names)

Here is an example cron job to grab The Daily Sucker from Vincent Flanders’ site once a day at 3:10 A.M. (it is created around midnight PST):

# grab the day feed for flanders' web pages that suck site
10 3 * * * /www/yourdir/cgi-bin/ > sucker.html

To save an HTTP request, you could merge this file within the destination page with a CGI script or a content management system (CMS). Alternatively, you could use a server-side include (SSI) to include it within your page, like this:

<!--#include virtual="/news/feeds/sucker.html" -->

In Microsoft IIS, you can use the AT command for the Schedule service to achieve a similar effect. The syntax is as follows:

at \\computername id / delete | /delete/yes
at \\computername time /interactive | /every:date,... /next:date,... command

For example, to back up the sales server at 11:30 P.M. every weekday, create a batch file that contains the backup commands in Backup.bat, and press Enter to schedule the backup:

function mainPageFunction (data) {
    // code that uses the iFrame data

Next, create the iframe to load the external JavaScript file. Note that iframes can cause layout problems, so the easiest way is to use a hidden iframe, like so (some browsers don’t like positioned iframes):

<div style="position:absolute;left:0;top:0;visibility:hidden;" id="datadiv">
    <iframe height="0" width="0">
        <script src="" type="text/javascript"></script>

Or you could load the data with an empty iframe, like so:

<iframe src="about:blank" height="0" width="0" name="dataframe"></iframe>
<script type="text/javascript">

Now, once you fill up JavaScript variables with data in the iframe, you can pass them to the main HTML page using the following code:

parent.mainPageFunction (data);
Copyright © 2002-2017 Website Optimization, LLC. All Rights Reserved - Free website speed test - Privacy Policy
Last modified: February 19, 2009.

Follow us on: Twitter, Google+, Facebook, Linked In