Forums
This topic is locked
Server caching pages for faster acces:: how?
31 Jul 2001 20:56:25 e site posted:
Hi UD'ers,I read somewhere sometime that you could make the server cache pages so that the next visitors instantly get the page.
This should/could be a huge speed advantage for any page that has a recordset, but doesn't update really frequently (e.g. like productpages)
Anyone who knows more on this?
Many thanx in adnvance <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
e_site
Replies
Replied 31 Jul 2001 22:27:06
31 Jul 2001 22:27:06 Bjorn Fripon replied:
Hi,
I think what you're trying to do here
has 2 ways of doing it ...
Server side caching :
(nice article on it)
www.asp101.com/articles/john/server_side_caching/index.asp
or
Stored Procedures
(thought this was MS Access/SQL only)
www.aspemporium.com/aspemporium/tutorials/storedprocedures.asp
or I also read something about
Connection Pooling
www.15seconds.com/faq/ODBC/481.htm
although I can't quite get my head around this one <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Maybe you could also look at the website of
your database ?
Hope this helps !
Good luck
Jezter
PS : Belgium rulez <img src=../images/dmxzone/forum/icon_smile_shock.gif border=0 align=middle>
PPS : Write a tutorial <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
I think what you're trying to do here
has 2 ways of doing it ...
Server side caching :
(nice article on it)
www.asp101.com/articles/john/server_side_caching/index.asp
or
Stored Procedures
(thought this was MS Access/SQL only)
www.aspemporium.com/aspemporium/tutorials/storedprocedures.asp
or I also read something about
Connection Pooling
www.15seconds.com/faq/ODBC/481.htm
although I can't quite get my head around this one <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Maybe you could also look at the website of
your database ?
Hope this helps !
Good luck
Jezter
PS : Belgium rulez <img src=../images/dmxzone/forum/icon_smile_shock.gif border=0 align=middle>
PPS : Write a tutorial <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
Replied 31 Jul 2001 23:11:41
31 Jul 2001 23:11:41 Tim Green replied:
Of course, this is assuming you are using the ASP server model.
If you are using PHP you can use the built in NoCache server behaviour which inserts this code :-
<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT" // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s" . " GMT" // always modified
header ("Cache-Control: no-cache, must-revalidate" // HTTP/1.1
header ("Pragma: no-cache" // HTTP/1.0
?>
I also seem to recall a server behaviour extension for ASP that achieves much the same effect. I believe it is available on the exchange.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
If you are using PHP you can use the built in NoCache server behaviour which inserts this code :-
<?php
header ("Expires: Mon, 26 Jul 1997 05:00:00 GMT" // Date in the past
header ("Last-Modified: " . gmdate("D, d M Y H:i:s" . " GMT" // always modified
header ("Cache-Control: no-cache, must-revalidate" // HTTP/1.1
header ("Pragma: no-cache" // HTTP/1.0
?>
I also seem to recall a server behaviour extension for ASP that achieves much the same effect. I believe it is available on the exchange.
Tim Green
Extension & PHP TalkZone Manager
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 01 Aug 2001 02:27:44
01 Aug 2001 02:27:44 Waldo Smeets replied:
Aren't there 2 ways of caching the pages? I have not read the artciles linked here by Jezter, but when looking at the PHP code from Tim I can see that this cache method is cleint-dependant (or am I wrong?). So this is not a nice solution when you have 1000 visitors each hour but you serve them the same products page over and over again.
So maybe the question should be: how to cache websites on the server instead of caching it in the clients browser?
I hope you all understand my point... now give me the answers <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Waldo Smeets - www.UDzone.com Webmaster
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
So maybe the question should be: how to cache websites on the server instead of caching it in the clients browser?
I hope you all understand my point... now give me the answers <img src=../images/dmxzone/forum/icon_smile_wink.gif border=0 align=middle>
Waldo Smeets - www.UDzone.com Webmaster
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Replied 01 Aug 2001 10:25:34
01 Aug 2001 10:25:34 Bjorn Fripon replied:
Waldo,
In this article it says that there are 3 forms of server side caching <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
1) Data Caching
What I mean by Data Caching is taking a copy of the data from the database or other slow data source (like external web pages) and storing it in a faster location. Where you store it is really dependent on how it'll be used and how quickly it needs to be accessed. In general, I tend to use Application level variables to store a disconnected / custom recordset or an array. Text or XML files can also be very useful for larger amounts of data that you're not willing to devote the memory to by storing it in an Application variable. The main issue with using files is that it slows things down. So, unless you're caching data from a very slow link, you might actually be slowing things down. That being said, I've used it quite often for caching http requests from other servers. Eventually this won't be needed, but with all the progress we've made, the web still isn't 100% reliable and it certainly isn't always fast. This way if I don't get an answer back or if it takes too long I can go to the cached version and at least give the user something besides an error!
While this method can substantially increase performance it still leaves us with the data in a state that we can manipulate it. In our example, we can not only build a select box of states, we could also display them in a table of the new quarters that have been released by the US Mint, or sort them into reverse order to really confuse people. In short, the data is still flexible and we can manipulate it easily in order to use it for a variety of purposes.
2) Element Caching
This takes Data Caching and goes one step further. If you know you're always going to be building a select box out of the state data then why are you caching the data itself and not the select box? The concept here is to speed things up even more by only doing the processing to build the box once and then caching the output. Then when you want to display the box again it's as quick and easy as simply doing a Response.Write.
While this method is faster and just as easy as Data Caching, the one drawback is that you do lose some of the flexability. Trying to build a table of states from a string containing a select box of the states is a lot of work and at that point it's probably easier to go back to the database to get the data again!
3) Page Caching
This is the ultimate in server-side caching. In this scenario we do all the processing ahead of time and build static .htm files. The benefit here is that there's no processing involved at all when requesting the cached files. The ASP interpreter never gets involved once the page is built. It's just as fast as if you had hand written the page and hard coded the data in... except for the fact that you didn't have to do it by hand! There are a couple different ways to build the files. In the example I just use the FileSystemObject to write the text I want in the file because it's simple to illustrate and you won't need to install a component. Many people find using a HTTP component to retrieve the dynamic file from the web server and then writing it out to a static file to be easier... especially if you're attempting to cache multiple pages.
The main drawback here is that determining when to refresh the cache can be a little difficult since no processing is happening. You can't do it in the page itself since it doesn't process. You also can't use global.asa unless you've got other asp files in the web being requested so it'll run (a decent option if you're just caching a few high traffic pages). Otherwise, you're pretty much left to refreshing the cache on your own or setting up a scheduler to do it for you.
Because this is a little more complex and I know there's a product that does this well, I feel I'd be remiss if I didn't mention XBuilder and XCache. Both products address page level caching, but they do it in slightly different ways. For more information see the link at the end of this article.
Anyway, you can read the whole article on
www.asp101.com/articles/john/server_side_caching/index.asp
Hopes this helps ...
Jezter
In this article it says that there are 3 forms of server side caching <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle>
1) Data Caching
What I mean by Data Caching is taking a copy of the data from the database or other slow data source (like external web pages) and storing it in a faster location. Where you store it is really dependent on how it'll be used and how quickly it needs to be accessed. In general, I tend to use Application level variables to store a disconnected / custom recordset or an array. Text or XML files can also be very useful for larger amounts of data that you're not willing to devote the memory to by storing it in an Application variable. The main issue with using files is that it slows things down. So, unless you're caching data from a very slow link, you might actually be slowing things down. That being said, I've used it quite often for caching http requests from other servers. Eventually this won't be needed, but with all the progress we've made, the web still isn't 100% reliable and it certainly isn't always fast. This way if I don't get an answer back or if it takes too long I can go to the cached version and at least give the user something besides an error!
While this method can substantially increase performance it still leaves us with the data in a state that we can manipulate it. In our example, we can not only build a select box of states, we could also display them in a table of the new quarters that have been released by the US Mint, or sort them into reverse order to really confuse people. In short, the data is still flexible and we can manipulate it easily in order to use it for a variety of purposes.
2) Element Caching
This takes Data Caching and goes one step further. If you know you're always going to be building a select box out of the state data then why are you caching the data itself and not the select box? The concept here is to speed things up even more by only doing the processing to build the box once and then caching the output. Then when you want to display the box again it's as quick and easy as simply doing a Response.Write.
While this method is faster and just as easy as Data Caching, the one drawback is that you do lose some of the flexability. Trying to build a table of states from a string containing a select box of the states is a lot of work and at that point it's probably easier to go back to the database to get the data again!
3) Page Caching
This is the ultimate in server-side caching. In this scenario we do all the processing ahead of time and build static .htm files. The benefit here is that there's no processing involved at all when requesting the cached files. The ASP interpreter never gets involved once the page is built. It's just as fast as if you had hand written the page and hard coded the data in... except for the fact that you didn't have to do it by hand! There are a couple different ways to build the files. In the example I just use the FileSystemObject to write the text I want in the file because it's simple to illustrate and you won't need to install a component. Many people find using a HTTP component to retrieve the dynamic file from the web server and then writing it out to a static file to be easier... especially if you're attempting to cache multiple pages.
The main drawback here is that determining when to refresh the cache can be a little difficult since no processing is happening. You can't do it in the page itself since it doesn't process. You also can't use global.asa unless you've got other asp files in the web being requested so it'll run (a decent option if you're just caching a few high traffic pages). Otherwise, you're pretty much left to refreshing the cache on your own or setting up a scheduler to do it for you.
Because this is a little more complex and I know there's a product that does this well, I feel I'd be remiss if I didn't mention XBuilder and XCache. Both products address page level caching, but they do it in slightly different ways. For more information see the link at the end of this article.
Anyway, you can read the whole article on
www.asp101.com/articles/john/server_side_caching/index.asp
Hopes this helps ...
Jezter
Replied 01 Aug 2001 10:57:26
01 Aug 2001 10:57:26 Waldo Smeets replied:
Wow, this is a tutorial on it self <img src=../images/dmxzone/forum/icon_smile.gif border=0 align=middle> Thank you very much. Damn I should have read the article before postingmy comments.
Thanks Jezter!
Waldo Smeets - www.UDzone.com Webmaster
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>
Thanks Jezter!
Waldo Smeets - www.UDzone.com Webmaster
<font size=1>-------------------------------------------
<i>Please read the Forum FAQ before posting
a question to this TalkZone.</i>
-------------------------------------------
www.UDzone.com : A dynamic Dreamweaver,
Ultradev and Fireworks site for developers
by developers.
-------------------------------------------</font id=size1>