Author Topic: PHP Caching Question  (Read 3547 times)

0 Members and 1 Guest are viewing this topic.

Offline anchorageweather

  • Forecaster
  • *****
  • Posts: 445
    • http://eetee.us/station/station.php
PHP Caching Question
« on: December 13, 2006, 08:15:41 AM »
Hello all:

I am hoping someone can help me.  I would like to cache a called page on my site (to save server load on the NWS).  The simple code is here:

Code: [Select]

<?php

$html 
implode&#40;'', file&#40;'http&#58;//www.crh.noaa.gov/lmk/index.php?mystation=KLOU'&#41;&#41;;

     

      
preg_match&#40;'|valign="middle" height="55" width="80">&#40;.*&#41;width="100" nowrap="nowrap"|s', $html, $betweenspan&#41;; 
      
$currenticon  $betweenspan[1&#93;; 

?>



I tried adding the additional code myself.  I was able to get the caching to work as a separate file; however, when I add the code to my site - it conflicts with Tom's forecast script (he is also cashing his information in his script).  Is there a way I can cache this called page AND Tom's called forecast page as well?  THANKS for any help!!!!
South of the Tracks, Anchorage, KY

Offline saratogaWX

  • Administrator
  • Forecaster
  • *****
  • Posts: 8645
  • Saratoga, CA, USA Weather - free PHP scripts
    • Saratoga-Weather.org
Re: PHP Caching Question
« Reply #1 on: December 13, 2006, 01:16:40 PM »
The perils of having more than one included PHP script with identical function names...

The easy way is to copy Tom's cacheing script and rename it to 'function fetchUrlWithoutHanging2' (or just a different name), then call that function in your new script.

I know there's a PHP function to check if a function is defined, but I've had limited success with it.  The 'brute force' method above should always work :-)

Ken
Ken True/Saratoga, CA, USA main site: saratoga-weather.org
Davis VP1+ FARS, Boltek-PCI/NexStorm, microSferics ToA, Blitzortung RED, GRLevel3, WD, WL, VWS, Cumulus, Meteobridge/hub
Free weather PHP scripts/website templates - update notifications on Twitter saratogaWXPHP

Offline anchorageweather

  • Forecaster
  • *****
  • Posts: 445
    • http://eetee.us/station/station.php
Re: PHP Caching Question
« Reply #2 on: December 13, 2006, 02:24:21 PM »
Quote from: "kenmtrue"
The perils of having more than one included PHP script with identical function names...

The easy way is to copy Tom's cacheing script and rename it to 'function fetchUrlWithoutHanging2' (or just a different name), then call that function in your new script.

I know there's a PHP function to check if a function is defined, but I've had limited success with it.  The 'brute force' method above should always work :-)

Ken


Ken:

I THINK I know what you mean, I'll give what you say a go, and see what happens.  Thanks for the feedback!!!!
South of the Tracks, Anchorage, KY

Offline anchorageweather

  • Forecaster
  • *****
  • Posts: 445
    • http://eetee.us/station/station.php
Re: PHP Caching Question
« Reply #3 on: December 13, 2006, 08:19:14 PM »
Quote from: "kenmtrue"
The perils of having more than one included PHP script with identical function names...

The easy way is to copy Tom's cacheing script and rename it to 'function fetchUrlWithoutHanging2' (or just a different name), then call that function in your new script.

I know there's a PHP function to check if a function is defined, but I've had limited success with it.  The 'brute force' method above should always work :-)

Ken


Ken:

Thanks for the help.  I got it worked out.  A lot of work for one current condition icon.
South of the Tracks, Anchorage, KY

 

anything