سؤال

I have a page which looks like this:

<!doctype html>
<head></head>
<body>
    <div>Content 1000 chars</div>
    <div>Content 1000 chars</div>
    <div>Content 1000 chars</div>
</body>
</html>

When a client downloads the page, basically he's downloading 3100 characters. If he visits the page again and the contents of the first div changes, he will have to redownload the entire page again (3100 characters).

Now basically I was wondering are we able to cache HTML fragments like the way we do with images?

So I was thinking is there somewhere to get this effect:

 <!doctype html>
<head></head>
<body>
    <div src="page1.html"></div>
    <div src="page2.html"></div>
    <div src="page3.html"></div>
</body>
</html>

So if I were to change the contents of page1.html, the browser would be able to know that only page1.html was changed since the last visit, and downloads 1000 characters instead of the entire page (3100) characters. Essentially this behavior is identical to what is happening now with images:

 <!doctype html>
<head></head>
<body>
    <img src="img1.gif">
    <img src="img2.gif">
    <img src="img3.gif">
</body>
</html>

whereby changing img1.gif will invoke the browser to redownload only img1.gif (assuming all the other files have not been edited)

To be clear, I'm not looking for an AJAX solution. I need a solution that works without javascript (as with all the above examples). I'm also not particularly in favor of the frames solution, However I would accept that as answer if there are simply no other alternatives / quirks / hacks

لا يوجد حل صحيح

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top