Re: cache control with javascript

From: Date: Tue, 21 Oct 2003 15:56:05 +0000
Subject: Re: cache control with javascript
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166968@lists.php.net to get a copy of this message
On 2003.10.21, at 22:28 Asia/Tokyo, Joshua Minnie wrote:
The "it" that you were asking about was the server. The javascript file is actually a PHP file that produces the JavaScript that I need. I only have one access to a database and a while loop to generate the code. Here is the code pieces:
...[snipped_code]...
The customer database can get potentially large so that this file could take a while to generate. Currently there are only 300 records but I anticipate many more. Does anyone have any recommendations that might speed this up?
Hmm... I think you missed the point earlier. Here's the basic idea. Create/generate a separate file ("whatever.js") [1] and make sure that this file is ONLY *updated* when necessary (e.g. updated database)[2]. Call this file inside your HTML <head> tags. [3] This way, the "whatever.js" will be "cached" whenever possible. - E - [1] Check the file functions in the manual (if you're not familiar with it already).
    (http://www.php.net/manual/en/ref.filesystem.php)
[2] Tip: Have a separate php script that generates the "whatever.js".
    Use/run this script ONLY after you made an update to your database.
[3] Something like this: <head>
    <script src="/path/to/whatever.js" language="javascript" type="text/javascript"></script>
</head> __________________________________________________ Do You Yahoo!? Yahoo! BB is Broadband by Yahoo! http://bb.yahoo.co.jp/

« previous php.general (#166968) next »