Jump to content

Just wondering about "overhead cost" (?) of includes


brucemand

Recommended Posts

am not sure if i'm using the correct terminology, but what exactly happens when an include-d file is served by PHP ?does everything it contains, get reloaded (re-"transferred" ?)to the client's browser and not get drawn from the cache ?if there are <img src="url">, i assume that those would be drawn from the cache, but does this work as well with, say, copious amounts of text ?would it be better to have a .txt file on the client side to draw from - how would this be achieved ?something like <iframe src="somefile.txt"> ?

Link to comment
Share on other sites

If you include a bunch of text, the browser has no way of telling what's been included and what has not, so none of it gets cached, except:In principle, a GET request, especially one sent with/without a query string in the URL bar, should always retrieve the same data, so unless the browser receives a header saying not to, it will probably cache the whole document (not just the included parts).As long as we're talking normal amounts of text, though, don't worry about it not being cached. Under 10K of text (which is a lot) should not cause notable slowdown. What slows down most documents is images. Optimize them first.

Link to comment
Share on other sites

how about this part;

##CUT##would it be better to have a .txt file on the client side to draw from - how would this be achieved ?something like <iframe src="somefile.txt"> ?
is the reasoning valid ? insignificant savings notwithstanding.
If you include a bunch of text, the browser has no way of telling what's been included and what has not, so none of it gets cached, except:In principle, a GET request, especially one sent with/without a query string in the URL bar, should always retrieve the same data, so unless the browser receives a header saying not to, it will probably cache the whole document (not just the included parts).As long as we're talking normal amounts of text, though, don't worry about it not being cached. Under 10K of text (which is a lot) should not cause notable slowdown. What slows down most documents is images. Optimize them first.
yeah, don't get me started on that, they may not be programmers, but even normal users attaching photos in e-mails couldn't be bothered converting them from their 10Mpx camera to something more web-reasonable ! :) re; GET request; so something like (a hypothetical example);http://w3school.invisionzone.co.us/index.php?page=34&item=3would be cached ?
Link to comment
Share on other sites

...would be cached ?
If index.php has not been modified, then developers should expect the page generated by that URL to be cached. This is a key distinguishing feature between GET requests and POST requests.Some behaviors cannot be accomplished without iframes, but usually there is a better way. Avoid them whenever possible, and especially avoid them if they contain links.If you're just trying to save some download time, ask yourself how big that .txt file is. If it's > 10K, this is a technique you might consider. If not, you probably want to stick with server-side includes. (And I'm talking a real 10K, not the number of bytes allocated by the server OS, which can be a lot more.)
Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...