[NTLUG:Discuss] Need PHP/HTML help.
Stuart Johnston
saj at thecommune.net
Thu Jan 6 16:15:51 CST 2011
On 01/06/2011 03:51 PM, steve at sjbaker.org wrote:
>> Since you are including myscript.php into index.php, the
>> browser will only see one page - index.php.
>> Remember, all php code is rendered out before the browser
>> sees the page. All it knows is the HTML result.
>
> Doh! Yes - that makes sense - I should have realized that.
>
>> The gigantic JavaScripts will be cached, but will need to
>> load each time a user first visits your page.
>
> Each time he "first" visits the page - you mean each time he restarts his
> browser and re-visits - or each time he revisits...period?
"Load" meaning read, compile, execute, etc. This happens on each visit
regardless of caching but does not involve a request from the server.
> What I guess I need to know is whether the JavaScript files that are
> pulled in with<script src="...."> are cached separately from the PHP/HTML
> that the script tag lives in...and I guess the answer is "Yes" - which is
> exactly what I was hoping for.
The answer is Yes.
> But there seems to be no obvious way for a
> ".js" file to have a header telling us what cache strategy to use...so I'm
> stuck with some kind of default behavior?
The best way to modify caching behavior is with headers, not HTML meta
tags. This can be done for any file by configuring your web server.
Someone else mentioned using an .htaccess file, for example.
>
>> I think
>> you should check if you really need all that JavaScript.
>> It will slow down the user experience. Also remember, the
>> JavaScript has to be executed on the browser so it will
>> take cycles on their machine. I find JavaScript laden
>> pages make the browser quite sluggish.
>
> Well, this is really a special case. I'm writing a 3D game using the new
> WebGL 3D graphics stuff, check out a screen-shot:
>
> http://www.sjbaker.org/tmp/1stPerson.png
>
> This is native, inside the browser, no plugins or downloads of any kind!
WOWZA.
> I have 3D model meshes stored as enormous JavaScript arrays (they could be
> JSON data - but then I don't believe they could possibly be cached) -
> these are automatically generated from a "blender" 3D model file.
JSON data can certainly be cached (see above). You could potentially
load individual models as needed rather than all up front.
I hope you will share the final product with us when it is ready!
More information about the Discuss
mailing list