Re: [PHP] Expiring other resources with HTTP headers
El lun, 27-02-2006 a las 12:35 -0500, tedd escribió: ps: your email address has generated a couple of bounced blog stuff thus far. Yeah, I seen that a couple of time now. What is going on? I have not anything to do with blogger.com, I don't know what is happening. What can I do to solve this? I don't want to annoy everyone in the mailing list. -William I don't know -- but if I try to send anything to: mailto:[EMAIL PROTECTED] I receive an error message stating something about failing to blog. tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
El lun, 27-02-2006 a las 12:35 -0500, tedd escribió: > ps: your email address has generated a couple of bounced blog stuff thus far. Yeah, I seen that a couple of time now. What is going on? I have not anything to do with blogger.com, I don't know what is happening. What can I do to solve this? I don't want to annoy everyone in the mailing list. -William -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
William said: That's not exactly what I am looking for. That would cause the JavaScript file to be requested to the web server every single time. I just want the browser to request the file only when it have been modified on the server. Let's say that by default, those JavaScript files expires every 4 hours and that when a PHP program regenerates the file in the server it should, somehow, notify the web browser that the file changed and that it should request that file the next time it reloads the page or else the user will be seeing an outdated menu. I am almost sure this is not posible using HTTP headers. The only way I see this could be achieved is by sending some random parameter to the JS file so that the browser thinks it is a different file. This was suggested by David Tulloh in a previous email. William: I may not understand what you're trying to do -- but, perhaps using something like: In concert with what I suggested might work. tedd ps: your email address has generated a couple of bounced blog stuff thus far. > William: Include this: HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
William Lovaton wrote: Let's say that by default, those JavaScript files expires every 4 hours and that when a PHP program regenerates the file in the server it should, somehow, notify the web browser that the file changed and that it should request that file the next time it reloads the page or else the user will be seeing an outdated menu. I am almost sure this is not posible using HTTP headers. The only way I see this could be achieved is by sending some random parameter to the JS file so that the browser thinks it is a different file. This was suggested by David Tulloh in a previous email. The best way I've found to do this is to put the file modification time in the querystring for the JS file. Set the expiry for that file to 365 days (or whatever) using Apache. That way you don't need to do anything when you update the JS file for it to be rolled out and the only cost per request is looking up the file modification time. Another way to do it is to store the version number actually in the JS filename itself. This would have the added benefit of being able to quickly rollback to a previous version if needed. Hope that helps. -Stut -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
Hi Tedd, That's not exactly what I am looking for. That would cause the JavaScript file to be requested to the web server every single time. I just want the browser to request the file only when it have been modified on the server. Let's say that by default, those JavaScript files expires every 4 hours and that when a PHP program regenerates the file in the server it should, somehow, notify the web browser that the file changed and that it should request that file the next time it reloads the page or else the user will be seeing an outdated menu. I am almost sure this is not posible using HTTP headers. The only way I see this could be achieved is by sending some random parameter to the JS file so that the browser thinks it is a different file. This was suggested by David Tulloh in a previous email. Thanks again, -William El lun, 27-02-2006 a las 11:12 -0500, tedd escribió: > >I know I could reduce the expiration time to reduce this problem but > >most of the time those files do not change. What can I do to notify the > >web browser that the file in the cache is no longer valid? > > > >-William > > William: > > Include this: > > // this script prevents all caching > > // expires on any past date > header ("Expires: Mon, 26 Jul 1997 05:00: GMT"); > > // last modified at current date and time > header ("Last-Modified: " . gmdate("D, d M Y H:i:s") . "GMT"); > > // for HTTP 1.1: > header ("Cache-Control: no-store, no-cache, must-revalidate"); > header ("Cache-Control: post-check=0, pre-check=0", false); > > // for HTTP 1.0 > header ("Pragma: no-cache"); > ?> > > HTH's > > tedd > -- > > http://sperling.com > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
I know I could reduce the expiration time to reduce this problem but most of the time those files do not change. What can I do to notify the web browser that the file in the cache is no longer valid? -William William: Include this: HTH's tedd -- http://sperling.com -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
Nice idea... thanks. I agree with you that the ability to expire another file would be somewhat risky but I fail to see how this could be exploited. May be the browser should allow this kind of operations from pages coming from the same server. But again, I don't think this is posible to begin with, I just wanted to make sure about that. Thanks again, -William El mar, 28-02-2006 a las 02:35 +1100, David Tulloh escribió: > I don't think you can expire another file, I would consider any ability > to do so a bug in the browser. Someone with too much time on their > hands could possibly turn something like that into a security risk. > > I would solve the changing javascript problem by subtly altering the > pages that use the javascript file. A web browser will recognise > menu.js, menu.js?ver=1 and menu.js?ver=2 as different pages. You can > use this for your application by including menu.js?ver=$ver in each of > your pages. When the menu is modified and regenerated, increment $ver. > Every client will refetch menu.js as it views it as a different file. > > > David > > William Lovaton wrote: > > Hello everybody, > > > > I write here to find out if this is possible: > > > > I want to expire an static file in the web browser through an HTTP > > header (Expires, Cache-Control or something else) sent from a PHP > > program. The usual thing is that those headers apply only to the > > program or file sending those headers, what I want is that a program > > sends those headers to affect a different file in the browser cache. > > > > In more detail, My web app generates a JavaScript file from the > > information stored in the database, that file represents the user menu > > and it is what the user sees in the web browser. Now, through an apache > > directive I set expiration times for several kinds of static resources > > so the web server doesn't get slash dotted with lots of unnecessary > > requests (this is a web app with lots of traffic). > > > > Although the JavaScript files are generated from PHP, it is seen as > > static content from the web browser POV. Right now I have set the > > expiration time for the menu files to 20 minutes. But let's say an > > admin user change the permissions of a user and the affected user hits a > > link that says "Regenerate menu". What will happen is that the > > JavaScript file will be regenerated on the web server but there is a > > chance that the browser won't see the change because the file is still > > valid in the cache. > > > > I know I could reduce the expiration time to reduce this problem but > > most of the time those files do not change. What can I do to notify the > > web browser that the file in the cache is no longer valid? > > > > I hope there is enough information here and that somebody can give me a > > hint in the right direction. > > > > Thanks, > > > > -William > > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
Re: [PHP] Expiring other resources with HTTP headers
I don't think you can expire another file, I would consider any ability to do so a bug in the browser. Someone with too much time on their hands could possibly turn something like that into a security risk. I would solve the changing javascript problem by subtly altering the pages that use the javascript file. A web browser will recognise menu.js, menu.js?ver=1 and menu.js?ver=2 as different pages. You can use this for your application by including menu.js?ver=$ver in each of your pages. When the menu is modified and regenerated, increment $ver. Every client will refetch menu.js as it views it as a different file. David William Lovaton wrote: > Hello everybody, > > I write here to find out if this is possible: > > I want to expire an static file in the web browser through an HTTP > header (Expires, Cache-Control or something else) sent from a PHP > program. The usual thing is that those headers apply only to the > program or file sending those headers, what I want is that a program > sends those headers to affect a different file in the browser cache. > > In more detail, My web app generates a JavaScript file from the > information stored in the database, that file represents the user menu > and it is what the user sees in the web browser. Now, through an apache > directive I set expiration times for several kinds of static resources > so the web server doesn't get slash dotted with lots of unnecessary > requests (this is a web app with lots of traffic). > > Although the JavaScript files are generated from PHP, it is seen as > static content from the web browser POV. Right now I have set the > expiration time for the menu files to 20 minutes. But let's say an > admin user change the permissions of a user and the affected user hits a > link that says "Regenerate menu". What will happen is that the > JavaScript file will be regenerated on the web server but there is a > chance that the browser won't see the change because the file is still > valid in the cache. > > I know I could reduce the expiration time to reduce this problem but > most of the time those files do not change. What can I do to notify the > web browser that the file in the cache is no longer valid? > > I hope there is enough information here and that somebody can give me a > hint in the right direction. > > Thanks, > > -William > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php
[PHP] Expiring other resources with HTTP headers
Hello everybody, I write here to find out if this is possible: I want to expire an static file in the web browser through an HTTP header (Expires, Cache-Control or something else) sent from a PHP program. The usual thing is that those headers apply only to the program or file sending those headers, what I want is that a program sends those headers to affect a different file in the browser cache. In more detail, My web app generates a JavaScript file from the information stored in the database, that file represents the user menu and it is what the user sees in the web browser. Now, through an apache directive I set expiration times for several kinds of static resources so the web server doesn't get slash dotted with lots of unnecessary requests (this is a web app with lots of traffic). Although the JavaScript files are generated from PHP, it is seen as static content from the web browser POV. Right now I have set the expiration time for the menu files to 20 minutes. But let's say an admin user change the permissions of a user and the affected user hits a link that says "Regenerate menu". What will happen is that the JavaScript file will be regenerated on the web server but there is a chance that the browser won't see the change because the file is still valid in the cache. I know I could reduce the expiration time to reduce this problem but most of the time those files do not change. What can I do to notify the web browser that the file in the cache is no longer valid? I hope there is enough information here and that somebody can give me a hint in the right direction. Thanks, -William -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php