Jump to content

JavaScript & CSS Source file loading efficiency


barneyf

Recommended Posts

I am building an application where PHP will refresh the web page on user command.  I have references to a CSS and JavaScript file in the head section of the document:

 

<head>
<script type="text/javascript" src="myscript.js"></script>
<link rel="stylesheet" type="text/css" href="main.css" />
</head>

 

Does the browser (FireFox or IE) re-load the CSS & JavaScript source files every time the page is re-sent?  Or is it smart enough to know it already has it loaded?

 

I am using CSS frames, not HTML frames and I am not ready to go to Web 2.0 with Ajax & etc just yet.  So if the browser blindly loads the files each time, is there a simple workaround?

 

Thanks

I hate the phrase Web 2.0.

 

 

 

And yes, browsers are smart enough to cache things, assuming the server is intelligent enough to know it's cached.  (Even IE does somethings right.  Weird, eh?)

 

 

The way it basically works is this (there are other factors, such as whether the server tells the client to cache the content or not):

 

*Client connects to server*

*Client sends request to server for something, but also says if it has a cached copy, and if so, when the cached copy was cached.*

*If the cached copy on the client side is the newest version, the server just tells the client that and nothing is transfered.*

 

 

So yes, there is a little bandwidth used because of the HTTP headers, but the entire file is not transfered.

Archived

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

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.