Solved

Partial Web page caching?

Posted on 2004-08-17
21
613 Views
Last Modified: 2008-03-03
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.
0
Comment
Question by:majnun
  • 4
  • 4
  • 3
  • +6
21 Comments
 
LVL 9

Assisted Solution

by:prifre
prifre earned 71 total points
ID: 11827361

I think what is cached is mainly controlled by the users browsers settings.

How to clear a browsers cache can be read about at: http://www.chami.com/tips/internet/021198I.html

Youcan prevent caching. But I believe you cannot control wheter parts of pages are cached or not. You can read about caching at http://www.htmlgoodies.com/beyond/nocache.html (good text and explanations).

With a smile
/prifre
0
 
LVL 9

Expert Comment

by:prifre
ID: 11827365
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
0
 
LVL 2

Assisted Solution

by:phpisthefuture
phpisthefuture earned 71 total points
ID: 11827719
This is not a question about clearing your cache or designing a webpage with frames. The question is partial caching of dynamic content. Let me give you some overview perspective first of all:
Dynamic content caching maximizes performance and scalability
Dynamic content caching solutions address the scaling and performance issues of Web servers directly. They work well for heavily visited sites containing many dynamic features that must be tuned to respond quickly and easily. For a growing company anticipating reaching the Web server's maximum processing power, dynamic content caching solutions will expand the Web server’s capacity more effectively than adding additional hardware to manage the load. In certain cases, server-side dynamic caching may be 20 to 100 times faster than processing the page normally.

Two factors to keep in mind when considering whether to cache dynamic pages include frequency of content changes and demand level for current content (hit count). Anticipated hit count determines the prioritization of pages to be cache. More popular pages take precedence over less frequently accessed pages. Some caching solutions provide analysis of script popularity on the site.

What is the programming language/s used on your website. Please provide more details about your side, then I can help you with specific solution.
Some softwares for partial page caching:
http://www.xcache.com/home/default.asp?c=45&p=297
http://www.sitellite.org/index/news-app/story.29/pagenum.3
http://www.zend.com/store/products/performance_partial_output_caching.php
0
 
LVL 2

Expert Comment

by:phpisthefuture
ID: 11827722
"site" becomes "side" after midnight :). Sorry for the typo.
0
 
LVL 36

Assisted Solution

by:Zyloch
Zyloch earned 71 total points
ID: 11827875
There are quite a bit of tutorials for ASP.NET partial caching. Not so much for other languages, but like phpisthefuture indicated above, there are software made for other languages.


http://aspnet.4guysfromrolla.com/articles/022802-1.aspx
the Partial-Cache section at the bottom. It's only a paragraph long but should be helpful if you have some experience in ASP
0
 
LVL 53

Accepted Solution

by:
COBOLdinosaur earned 74 total points
ID: 11830755
Hmmm... well a lot of interesting noise about server side caching, but as the quesion is about caching on the browser, I think I'll just address the question.

You cannot force the browser to cache anything.  You can include caching instructions at the page level, but the browser takes its instructions from the user not the web page.  Generally when users do not allow caching it is because they have a fast connection and are not concerned with load times. The browser actually save everything downloaded to the hardrive anyway. Caching is not a matter of getting it saved on th client, is is a matter of getting the browser to use what is on the harddrive instead of re-loading. You cannot control that; nor should you be able to, because it would mean that web sites would detemine how the users resources are allocated, and it would be abused by sites to that would reduce server load by using large amounts of the users' disk space.

So if you need caching, you go back to the previously posted noise and see if server side caching is of any help to you.

Cd&
0
 
LVL 2

Assisted Solution

by:rlovetx
rlovetx earned 71 total points
ID: 11831748
COBOLdinosaur is correct.

To add to it:  for most browsers, once a user downloads a CSS file or a graphic, the browser will not re-download the file.  So, if you reuse images on several pages (for example, a header graphic and a global CSS file used by all pages), the user takes the hit on the home page and not again.  So, a home page might be 40kb in total (with graphics and CSS file), but each successive page request will only take in the changed data, which might be 20k.

Here in the West of Ireland, our dialup lines are very poor and broadband isn't available outside the main towns.  So, our websites make light use of graphics and reuse files as much as possible to minimise the download sizes for the users (and their download times).
0
 
LVL 9

Expert Comment

by:prifre
ID: 11835473
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
0
 

Author Comment

by:majnun
ID: 11836690
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!

0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11836766
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&
0
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 36

Expert Comment

by:Zyloch
ID: 11850439
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 :)
0
 

Author Comment

by:majnun
ID: 11857351
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...

0
 
LVL 9

Expert Comment

by:prifre
ID: 11858183
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
0
 
LVL 10

Expert Comment

by:eeBlueShadow
ID: 11858429
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?
0
 
LVL 36

Expert Comment

by:Zyloch
ID: 11861961
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...............................
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 11864300
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&
0
 
LVL 2

Assisted Solution

by:Epistemo
Epistemo earned 71 total points
ID: 11879090
Use squid.
 > http://www.squid-cache.org/
You can assign timeouts on every mimetype and/or itemtype...

Also ... need to know what server you are using.

Apache has some options in there.
IIS can be done with some modifications in the cache settings of the server.

You are talking about different time-outs for different file formats ... and so
you need to do this server side. I use Squid myself. Small footprint and fast.
Meta stuff, etc will not work.




0
 

Assisted Solution

by:compac
compac earned 71 total points
ID: 11918864
Your Question :
"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."

My answer to this is my own private workaround for 'includes' - it goes like this.  I put the entire navbar in a js file like this -

document.write(" <Menu stuff in html but with single quotes instead of double, and NO carriage returns.>;") - and call it with the usual inline JS code call <SCRIPT LANGUAGE="JavaScript" src="menu.js"></SCRIPT>

These act exactly like includes, and I use them on every page on the site.  Together with lots of CSS, it means pages are mainly actual content, rather than code with good load times.

Provided the user is using their cache, the CSS, JS, and Image files are downloaded once and then served from the cache for each page. (If you don't use absolute paths for the called files and pics)
0
 
LVL 53

Expert Comment

by:COBOLdinosaur
ID: 12447831
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&
0
 

Author Comment

by:majnun
ID: 12454027
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).
0

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Preface This is the third article about the EE Collaborative Login Project. A Better Website Login System (http://www.experts-exchange.com/A_2902.html) introduces the Login System and shows how to implement a login page. The EE Collaborative Logi…
Styling your websites can become very complex. Here I'll show how SASS can help you better organize, maintain and reuse your CSS code.
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now