[NTLUG:Discuss] Need PHP/HTML help.

Stuart Johnston saj at thecommune.net
Wed Jan 5 21:19:12 CST 2011


As far as the client (browser) is concerned, index.php and  
myscript.php are the same page so the no-cache pragma should apply to  
the whole thing.  The js files are separate requests so they should be  
cached.  That is the short answer.  It can get much more complicated  
than that.  In particular, keep in mind that server configuration  
factors in as well.



Quoting Steve Baker <steve at sjbaker.org>:

> Sorry - I have a web/PHP question which is a bit OffTopic...but I'm
> desperate...and I know that there are a lot of web guru's here.
>
> I have a web page which is generated in PHP - and I'm concerned about
> caching behavior.
>
> The file "index.php" has a tiny bit of PHP code that does essentially
> just this:
>
>   <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"
> dir="ltr">
>   <head>
>   <?php
>       include_once "myscript.php" ;
>   ?>
>   </head>
>   <body>
>       ...stuff...
>   </body>
>   </html>
>
> ...and "myscript.php" contains:
>
>     <meta http-equiv="pragma" content="no-cache" />
>     <?php
>       ...calculate some stuff...
>       echo the_stuff ;
>     ?>
>     <script type="text/javascript" src="giganticScript_1.js" ></script>
>     <script type="text/javascript" src="giganticScript_2.js" ></script>
>     <script type="text/javascript" src="giganticScript_3.js" ></script>
>     <script type="text/javascript" src="giganticScript_4.js" ></script>
>    ....
>     <script type="text/javascript" src="giganticScript_50.js" ></script>
>
> The thing I'm concerned about is how all of this gets cached on the
> client-side.
>
> * "index.php" doesn't ever change...it always produces the same output
> it would be nice if it were cached - but it's not essential.
> * "myscript.php" doesn't change - but it IS going to produce different
> output every time they visit the page.  That's what I need...hence the
> "no-cache" thing.
> * all of the "giganticScript_N.js" files never change...and they are
> truly gigantic (multiple megabytes each!) so I desperately want them to
> be cached and not reloaded just because myscript changed.
>
> If I use    <meta http-equiv="pragma" content="no-cache" />   inside
> "myscript.php" - will it even be recognised if "index.php" is cached?
> Alternatively, if it works as I hope and reloads myscript even if
> index.php is cached - will it still cache my giganticScripts?
>
> I can't find anyplace where the behavior is clearly described.
>
>   -- Steve
>
>
> _______________________________________________
> http://www.ntlug.org/mailman/listinfo/discuss
>





More information about the Discuss mailing list