Link to home
Start Free TrialLog in
Avatar of majnun
majnun

asked on

Partial Web page caching?

Is it possible to ask a browser to cache some things and not others? For example cache images and media files, but not the actual page data?

I'm serving up dynamic content, but i don't want the user to have to download standard Nav bar images that exist on every page, etc.
SOLUTION
Avatar of prifre
prifre

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of prifre
prifre

Oh yeah - you can always divide the page up into subpages, by using frames. Then you can of course control wheter each part is cached or not via the "no-cache" solution...

/prifre
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
"site" becomes "side" after midnight :). Sorry for the typo.
SOLUTION
Avatar of Zyloch
Zyloch
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hi,

After reading the thread, I am quite pleased with my first answer...

You should decide if you need to control browserside-caching or serverside-caching.

For controlling browserside-caching, there are HTML-parameters that enables you to prevent caching. See my first post.

For serverside-caching, dynamic contents, etc there are a lot of interesting solution, but that would be dependent on the server possibilities...

With a smile
/prifre
Avatar of majnun

ASKER

Wow, that's a lot of comments that take me in many directions at once...

Let me spell out the particulars.

1) I'm using PHP (i'm familiar with .NET but for this application, its PHP only).

2) I have a nav bar using roll-over images (PNGs if it matters)

3) I've created a cross platform HTML only media player (using <embed> tags that are dynamically created by PHP spitting out the tag parameters) - i do not need any "embedded music sucks" comments, I have a stop button for those people... i'm actually creating a player (and yes, Flash rocks, but not in this application).

4) Because its a site i work on from time, if I make changes i want them to be seen right away by people. Currently I have a series of no-cache headers being sent to the browser by PHP. (and i could use meta tags to the same effect).

My question is this:
Considering my use of the no-cache headers / meta tags (and assuming the browsers comply):
Does the browser have to download each of the graphics in the nav bar, and the embedded audio each time they switch pages, assuming those images and that media have the same file extensions and file names on all the pages?

What i'm hoping is that I can tell the browsers "don't cache these pages" and yet they still use the local harddrive's copy of the images and embeded media. I'd hate for dialups to wait to download all that stuff each time they change pages. And i'd hate for someone to miss my changes because I don't have the no-cache headers.

Do or do not browsers which have been instructed not to cache a page still use the downloaded images/media if they view that page again? What about if that same media is used on other pages?

To further cloud the issue:
As far as the browser is concerned, each "page" of my website is a single page. The PHP serves up the content based on a page variable in the query request... for example the contact page has a URL of "www.mysite.com/index.php?page=contact" and my about us "page" has a URL of "www.mysite.com/index.php?page=about"

So in this regard, do browsers consider these seperate pages or the same page for functionality such as caching?

Thanks for all the fish!

USe the previously cached:

The answer POSITIVELY, ABSOLUTELY, GUARANTEED maybe...

IE depending on version build and SP may or may not(flip a coin).

Mozilla will most of the time, unless some of the pieces are coming cross-domain; then it will depend on user settings.  

Cd&
Ahh... well, you see, like Cd said above, the no-cache direcives, if used correctly, should stop a browser from caching, but you can never be sure that the browser will cache in the first place (especially IE... by the way, who knows how IE is made anyways besides the techno gurus at Microsoft? I wonder if it resembles spaghetti code...)

As to the no-cache, well, if you have that, it means the browser will have to go to your server every single time and download the image all over again. Otherwise, if your page is cached, then it might get the page from an intermediate proxy or the client's computer.

If you're PHP and don't want to spend money on the Zend stuff (who does?), I would suggest frames or iframes. Most browsers support them now (even iframes) and it just simplifies stuff a lot. Or you can just let the browser do its stuff and blame it on standards if the users are getting stale information :)
Avatar of majnun

ASKER

Ok so Cd& says images are still "cached" despite the no-cache, and Zyloch says images are downloaded with each request.

Can anyone verify either of these statements?

I have a high bandwidth connection so I can't tell if the images are being downloaded each time or not. I supposed I could upload a huge picture and see if it gets it everytime...

Hi,

Caching and "Temporary internet files" is almost the same thing. In Internet Explorer, caching is dependent on how:
Tools->Internet Options->General->Temporary Internet Files->Settings is setup.

So the answer is - it's dependent on how the user has set his browser. And that is the whole problem. How the user's browser works the web-site-creator cannot control.

I would recommend to try to use small images, effective pages, optimize the server side and let each user worry about the rest.

With a smile
/prifre
Since each image and CSS page and media file is seen as a separate request to the server, couldn't you use an htaccess to add no-cache headers to the php files and 'please-cache' headers to media files?
You have to be careful with using no-cache directives. As long as you send the correct headers, theoretically, browsers that support the standard should not cache, and I'll bet many of them don't, but then again, when the browser doesn't support standards correctly...............................
Like I already said:
"The answer POSITIVELY, ABSOLUTELY, GUARANTEED maybe... "

And that is as definitive as it is going to get, because even with the exact build and patches of the browser known; there is still the user setting ans ISP strategy to change what should be the default behaviour for the given browser.  

Cd&
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Well this is fun isn't it.  The answer to the questions is literally "depends..."

So as majnun, has choosen to be irresponsible in the management of their question I guess the best option is a split among every expert who gave any of yes, no, maybe, could be, or might be as an answer.

Cd&
Avatar of majnun

ASKER

Sorry... have been managing projects and not threads ;)

Its an odd internet world out there, with the most popular browser not fully standards compliant and different users personalizing things however they want, it makes it almost impossible to anticipate the needs of the users.

For now I'll put no-cache headers on pages with dynamic content, keep the filenames the same for media and graphics, and let the web browser/user settings deal with the implications.

I'm still not clear how the server-side partial caching things work, because once an HTML document is submitted to a webbrowser, the browser takes over, no? And if there aren't "partial-caching" html tags, how does a browser know the difference between content on a page you want it to cache and content on a page you don't want it to? Or in other words, what does the server use to tell the browser cache this file, don't cache this file?

I'm awarding points to everyone who offered a suggestion. I think I got everyone and split the points as even as i felt like computating. :)

Thanks all! (Sorry for neglecting the thread).