.NET Forum / ASP.NET / Caching / February 2004
DB caching the html rendered by a .aspx page
|
|
Thread rating:  |
Jon Maz - 30 Jan 2004 18:40 GMT Hi,
My goal is to take the entire html/javascript stream spat out by .aspx pages and save them as simple strings in a database (for caching purposes).
I'm not sure how I can get hold of this html stream, though - does anyone have any strategies / code samples to get me going?
Thanks,
JON
Scott M. - 30 Jan 2004 23:16 GMT You know, ASP.NET's OutputCache directive is VERY powerfull and does what you are looking for. Check it out first.
> Hi, > [quoted text clipped - 7 lines] > > JON Jon Maz - 31 Jan 2004 14:45 GMT Hi All,
Thanks for the replies.
I really *do* need to cache entire pages of html/javascript to a db - the number of pages involved is too great to cache in server memory, which is what (if I understand correctly) the built-in asp.net caching does. So it looks like I need some kind of custom solution here (feel free to correct me if I'm wrong about this).
The site, which is for a publishing company, will use a Content Management System to input dynamic content directly into the db. When the CMS user (a journalist) is creating new page content via the CMS, he should have the option to cache this new page immediately, ie before any site user has viewed the .aspx page in a browser.
Now I'm really not sure how to go about this. An aspx page has a public RenderControl method - should I be looking to use that somehow?
Any help appreciated,
Cheers,
JON
PS Also I'm not sure what the machine.config ProcessModel can do for me (Jayson's suggestion in microsoft.public.dotnet.framework). Can anyone elucidate?
Kevin Spencer - 31 Jan 2004 15:33 GMT Here's the thing, Jon. ASP.Net was architected in a certain way, and runs optimally when you use it that way. If you want to redesign the entire architecture, you're certainly free to do so. You can build your own HttpHandler if you want, starting all the way from the bottom. The CLR has everything you need.
You think your app is too big for ASP.Net to handle the way it is designed? Think again. Microsoft uses it on their web site. It was designed for immense scalability. If you use it the way it was designed to be used, it will certainly scale to your needs without you having to re-write the platform.
 Signature HTH, Kevin Spencer .Net Developer Microsoft MVP Big things are made up of lots of little things.
> Hi All, > [quoted text clipped - 29 lines] > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004 Jon Maz - 31 Jan 2004 18:54 GMT Hi Kevin,
You may well be right, but unfortunately the design of the app is not going to be my decision! The company is porting an existing web app / CMS from Classic Asp into asp.net, and the Classic Asp version cached html/javascript strings into a db. They've told me to go and find out how to replicate this in asp.net.
If I *also* come back with some brand new ideas about new caching methods that might serve better, then great, but my boss won't be too amused if I tell him I simply have no idea how to replicate this existing caching technique that always worked well for them. In fact the starting point of my research was (of course) the built-in caching objects in .net. My boss's response to articles on asp.net Caching (like http://aspnet.4guysfromrolla.com/articles/022802-1.aspx) was to say "we have over 30,000 articles to display on our site, you can't keep all that in server memory".
Perhaps I/he misunderstand how asp.net caching works, and it *doesn't* work by storing all cached data (in this case, 30,000+ articles) in memory. If so, great - maybe someone can explain to me how it does work.
But anyway, the task I've been given is find out how to cache html/javascript strings into a db using asp.net. Is it really the case that I'd have to build my own HttpHandler to do this?! Hope not....
Thanks for the help so far,
JON
vMike - 31 Jan 2004 20:42 GMT Jon, The code I provide in my previous post above will give you the actual html/javascript of the rendered page which you can save to a database. The remaining task of calling the page from the database instead of re-renderering the page would have to be built but could be based on the parameters of the data you save the database.
> Hi Kevin, > [quoted text clipped - 30 lines] > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004 Jon Maz - 31 Jan 2004 21:52 GMT Hi Mike,
Thanks for that, I'll see what I can do on the basis of your code snippet. Do you have any suggestions for how to call the page from the db?
The other thing I'm currently musing on is how to access the different html streams for different browsers. Do you know at what point the HtmlTextWriter checks which browser it is producing html for, and can you "pass a browser type as a parameter" to it?
Thanks again,
JON
vMike - 01 Feb 2004 01:46 GMT Your task sounds daunting and the potential for problems seems high. It may be worth doing some benchmarking with test data and see if reading from the database is faster than creating the pages on the fly. You might also do some testing with the built in cache (Remember that you can cache the data source, in whole or in part, and lots of other things like controls as well as caching output pages). Maybe those test might be useful in convincing others that the approach in dotnet should be different than asp. I don't have enough experience to tell you which way to go on it, but you should be able to use the code to save some pages and show that it can be done and you can use that info to do the testing. There are a lot of others on the newsgroup with a lot of experience that may have futher input.
Good Luck
> Hi Mike, > [quoted text clipped - 14 lines] > Checked by AVG anti-virus system (http://www.grisoft.com). > Version: 6.0.572 / Virus Database: 362 - Release Date: 27/01/2004 Eric Newton - 11 Feb 2004 17:56 GMT ...continuing the debate...
Jon, caching the final output back to the db is putting even MORE strain on the database machine... even if you use a caching server, ie a completely separate database machine to hold the cached pages, you'll still never reach local, in-memory caching performance.
Scalability of that solution is similar, however, IMO buying more RAM for web servers and adding more webservers to the front line is a lot cheaper and easier to maintain system then forcing a database backend to cache the result.
Your client should respect your knowledge in .Net, and acknowledge the fact that ASP.Net is almost completely different from Classic ASP, and in some cases is over 10 times faster, even before using caching of any type...
...just my two cents...
 Signature Eric Newton eric.at.ensoft-software.com www.ensoft-software.com C#/ASP.net Solutions developer
> Hi, > [quoted text clipped - 7 lines] > > JON Jon Maz - 11 Feb 2004 18:18 GMT ...just my two cents...
and thank you for them!
JON
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|