Re: [PHP] cache control with javascript

2003-10-21 Thread - Edwin -
On Mon, 20 Oct 2003 14:44:50 -0400
Joshua Minnie [EMAIL PROTECTED] wrote:

 Does anybody know how I can make force a javascript file (written in
 PHP) to be cached if the user agent allows it?
 
 Here is the situation:
 I am creating a dropdown menu system that contains a customer list,
 loaded from a database.  This list is written to the javascript file
 for the menu. The menu can be quite large as the data grows.  What I
 would like to do, is force it to be cached (unless of course the
 user agent doesn't allow it) so that it doesn't have to make the
 call to generate the file each time.

What is the second it in the last sentence above? A browser wouldn't
make the call to generate the javascript file each time.

 I have searched through the php.net website and even through the
 HTTP/1.1 protocols.  I am continuing to look, but have not found a
 definite answer as to whether or not what I am trying to do is
 possible.

Just make sure that the javascript is on a separate file (i.e.
whatever.js) and that it's NOT being generated by your (php) script
each time. Then, call that file from inside your html/php page.

- E -
__
Do You Yahoo!?
Yahoo! BB is Broadband by Yahoo!
http://bb.yahoo.co.jp/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cache control with javascript

2003-10-21 Thread Joshua Minnie
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:

[code]
// already connected to the db
$sql = SELECT * FROM Customers ORDER BY LastName ASC, FirstName ASC;
$result = mysql_query($sql) or die(mysql_error());

while($row = mysql_fetch_assoc($result)) {
// generate the javascript
}
[/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?

Josh

- Edwin - [EMAIL PROTECTED] wrote:
  Does anybody know how I can make force a javascript file (written in
  PHP) to be cached if the user agent allows it?
 
  Here is the situation:
  I am creating a dropdown menu system that contains a customer list,
  loaded from a database.  This list is written to the javascript file
  for the menu. The menu can be quite large as the data grows.  What I
  would like to do, is force it to be cached (unless of course the
  user agent doesn't allow it) so that it doesn't have to make the
  call to generate the file each time.

 What is the second it in the last sentence above? A browser wouldn't
 make the call to generate the javascript file each time.

  I have searched through the php.net website and even through the
  HTTP/1.1 protocols.  I am continuing to look, but have not found a
  definite answer as to whether or not what I am trying to do is
  possible.

 Just make sure that the javascript is on a separate file (i.e.
 whatever.js) and that it's NOT being generated by your (php) script
 each time. Then, call that file from inside your html/php page.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP] cache control with javascript

2003-10-21 Thread - Edwin -
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/
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] cache control with javascript

2003-10-21 Thread Joshua Minnie
That really helped, I didn't think about generating the file that way.  I
have done other things like that, but sometimes it just helps when you get
another set of eyes on the project at hand.  Thanks for the refresher.

Josh

-Original Message-
From: - Edwin - [mailto:[EMAIL PROTECTED]
Sent: Tuesday, October 21, 2003 11:56 AM
To: Joshua Minnie
Cc: [EMAIL PROTECTED]
Subject: Re: [PHP] cache control with javascript



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/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Cache Control

2002-05-31 Thread Jon Haworth

Hi Jeroen,

 Where i can find more help about cache control

Here: http://www.google.com/search?q=help+about+cache+control (495,000
results)

Or did you mean something a bit more specific?

Cheers
Jon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




RE: [PHP] Cache Control

2002-05-31 Thread Jeroen Timmers

indeed

more specific

Jeroen

At 11:00 31-5-2002 +0100, you wrote:
Hi Jeroen,

  Where i can find more help about cache control

Here: http://www.google.com/search?q=help+about+cache+control (495,000
results)

Or did you mean something a bit more specific?

Cheers
Jon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Cache Control

2002-05-31 Thread Jon Haworth


Hi Jeroen,
   Where i can find more help about cache control
 
  http://www.google.com/search?q=help+about+cache+control
  Or did you mean something a bit more specific?

 indeed
 more specific

Well, seeing as you're not sharing the actual question with the mailing
list, this answer may not be exactly what you're after, but it's probably:

meta http-equiv=Pragma content=no-cache
meta http-equiv=Cache-Control content=no-cache
meta http-equiv=Expires content=?=$a_GMT_date_in_the_past?

;-)

Cheers
Jon

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Fwd: RE: [PHP] Cache Control

2002-05-31 Thread Jeroen Timmers


Date: Fri, 31 May 2002 12:13:40 +0200
To: Jon Haworth [EMAIL PROTECTED]
From: Jeroen Timmers [EMAIL PROTECTED]
Subject: RE: [PHP] Cache Control

I want info on the internet where i can find a manuel.

I want a statement that de page always refresh

the page is a php script and sometimes it comes out of a proxy but
that is not allowed.

Thx Jeroen

At 11:11 31-5-2002 +0100, you wrote:

Hi Jeroen,
Where i can find more help about cache control
  
   http://www.google.com/search?q=help+about+cache+control
   Or did you mean something a bit more specific?
 
  indeed
  more specific

Well, seeing as you're not sharing the actual question with the mailing
list, this answer may not be exactly what you're after, but it's probably:

meta http-equiv=Pragma content=no-cache
meta http-equiv=Cache-Control content=no-cache
meta http-equiv=Expires content=?=$a_GMT_date_in_the_past?

;-)

Cheers
Jon

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



RE: [PHP] Cache Control

2002-05-31 Thread Jon Haworth

Hi Jeroen,

 I want info on the internet where i can find a manuel.

http://www.google.com/search?q=http+cache+control+headers

 the page is a php script and sometimes it comes out of a proxy but
 that is not allowed.

It's not something you have absolute control over - some proxies are
configured to ignore your caching instructions anyway.

Cheers
Jon

PS. Please try and avoid using HTML mail on lists.

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP] Cache Control with forms

2001-04-19 Thread Rasmus Lerdorf

 Hi everyone! I have the following problem:
 I don't want any of my site's pages to be saved on any  browser's cache.
 Yet, I want all HTML forms to keep their data when the user changes to
 another page without submiting and then comes back using the back button.

 I have seen changing the session.cache_limiter configuration option to
 'private' instead of 'nocache' works to make all forms keep their data, but
 then all pages are diplayed from the browser's cache even after refreshing
 several times!. I want a point in between, but I don't know how to get
 there.

 By the way, do you know what do the values that session.cache_limiter  can
 take mean? (nocache, private and public)

When you set it to 'nocache' you get a set of HTTP headers that look like
this:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0
Pragma: no-cache

That forces things to not be cached anywhere.

The 'private' setting sends these headers:

Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: private, max-age=10800, pre-check=10800

The expires header is set to a time in the past to force non-HTTP 1.1
compliant caches not to cache the page.  For HTTP-1.1 caches that
understand the cache-control header the page will be cached only in
private caches (ie. the end-user http-1.1 compliant browser) for the time
specified by the session.cache_expire setting.


The 'public' setting sends headers like this:

Expires: Thu, 19 Apr 2001 20:57:16 GMT
Cache-Control: public, max-age=10800

Basically this means that the page is allowed to be cached in both public
(like AOL's proxy-cache) and private caches for the time specified by
session.cache_expire

And no, I don't know of a way to do what you want.  I don't think you can
have the back button working and at the same time not allow private
caching.

-Rasmus


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]