|Much of the content on the site is read from the database once a day, and stored in Application variables for efficiency. Banners are a good example, as documented in this related article.|
Recently a few people have asked about how I reset these variables when I add a new affiliate site button or advertiser banner, so I thought I'd write it all down here.
What's the problem again?
As you probably know by now, I administer my database online using these pages, but after new data has been added to the relevant table it won't automatically show up on the site because the data is served from Application variables - a cache effectively - using code like that shown below:
|// put data from database in cache once a day
Application ( 'Banner' ) = '' + oRecordSet ( 'BannerHTML' );
// display cached HTML on page
Out ( Application ( 'Banner' ) );
Rather than waiting until midnight for the cache to be updated I needed a way to update it immediately. (Note: this isn't at all complicated, but it may help you re-use my code since this isn't documented anywhere else)
Refreshing BannersThe most common thing I want to do is refresh the banners and buttons after I've added one. To do that I simply call my ResetBanners.asp page (with my password appended to the URL). The guts of this page are shown below:
|// get password from URL
LookForMagicWord ( );
// if the correct password was given..
if ( bValidUser )
// ..refresh the banner cache
GetDaysBanners ( );
// go to front page
Redirect ( '/default.html' );
Very simple - I just make sure it's me calling the page, then call the same function GetDaysBanners as is called at midnight by the BrandNewday function. It's not rocket science, but now you know.
Refreshing other variablesHere is the complete list of "admin" pages: