
This is the Title of the Book, eMatter Edition
Copyright © 2007 O’Reilly & Associates, Inc. All rights reserved.
Using Cached Results When Working with HTTP for Faster Performance
|
823
That being said, if you are looking for a quick way to parse HTML in your applica-
tion and it is not a potential performance hotspot, this method will do quite nicely.
Like many other things in .NET, if you know what you are using it for and the scope
of the work it will do, many alternatives become acceptable.
See Also
See the “IHtmlDocument2 Interface” and “MSHTML” topics in the MSDN
documentation.
14.17 Using Cached Results When Working
with HTTP for Faster Performance
Problem
You are looking for a way to speed up code that reaches out to the Web via HTTP
for content.
Solution
Use the RequestCachePolicy class to determine how your HttpWebRequests react in the
presence of a caching entity.
RequestCachePolicy has seven levels defined by the
RequestCacheLevel enumeration, as shown in Table 14-3.
The RequestCachePolicy is set up using the CacheIfAvailable RequestCacheLevel so
that the request will always take the “closest” content to enhance retrieval speed. If
Default is used, the request is still subject to the underlying cache policy of the sys-
tem, and that can prevent the use of intermediate caches.
Table 14-3. RequestCacheLevel enumeration values
Flag value Purpose
BypassCache Get content only directly from the server ...