Re: Expiring other resources with HTTP headers
| From: | William Lovaton | Date: | Mon, 27 Feb 2006 16:11:34 +0000 |
| Subject: | Re: Expiring other resources with HTTP headers | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-231141@lists.php.net to get a copy of this message | ||
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
> >
>