473,385 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

WebRequest ignoring cache

First of all, I apologize. I wanted to post this in
microsoft.public.dotnet.framework (as it's a bit more appropriate there),
but Outlook Express is suddenly giving me errors whenever I go to that
newsgroup and I have to restart OE.

I'm using WebRequest and I want to bypass any caching in the proxy server.
Unfortunately, I don't have a proxy to test with.

My understanding is that I just need to pass a pragma: no-cache and
cache-control: no-cache (to avoid caching in the first place) in the header.
Do I simply add the headers as shown in the code below? Or do I need to do
something else?

WebRequest req = WebRequest.Create(url);
if (null != proxy)
{
req.Proxy = proxy;
}
using (WebResponse response = req.GetResponse())
{
req.Headers.Add("pragma", "no-cache");
req.Headers.Add("cache-control", "no-cache");
using (Stream stream = response.GetResponseStream())
{...
Thanks.

Pete
Nov 16 '05 #1
1 9971
Nevermind, figured it out from a second google search. I must have
misspelled something in the first because I was getting completely offtopics
responses.

Anyway, the code I guess was right except that I should be using
req.Headers.Set() instead of add. I'm not sure it matters, but that's what
the sample code did.

Pete

"Pete Davis" <pd******@NOSPAM.hotmail.com> wrote in message
news:iu********************@giganews.com...
First of all, I apologize. I wanted to post this in
microsoft.public.dotnet.framework (as it's a bit more appropriate there),
but Outlook Express is suddenly giving me errors whenever I go to that
newsgroup and I have to restart OE.

I'm using WebRequest and I want to bypass any caching in the proxy server.
Unfortunately, I don't have a proxy to test with.

My understanding is that I just need to pass a pragma: no-cache and
cache-control: no-cache (to avoid caching in the first place) in the header. Do I simply add the headers as shown in the code below? Or do I need to do
something else?

WebRequest req = WebRequest.Create(url);
if (null != proxy)
{
req.Proxy = proxy;
}
using (WebResponse response = req.GetResponse())
{
req.Headers.Add("pragma", "no-cache");
req.Headers.Add("cache-control", "no-cache");
using (Stream stream = response.GetResponseStream())
{...
Thanks.

Pete

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: William F. Robertson, Jr. | last post by:
I am having problems with using the WebRequest object (or HttpWebRequest ). I have created the WebRequest and set the credentials, but when I call GetResponse() it is throwing an internal server...
1
by: Dave | last post by:
I'm trying to make a webrequest to another server on our webfarm (to synch the cache as explained in http://www.eggheadcafe.com/articles/20030420.asp) but I'm getting a 401 unauthorized error. ...
0
by: WIWA | last post by:
Hi, I want to login to a password protected website and fetch the content of the page behind. I have based my code on http://weblogs.asp.net/jdennany/archive/2005/04/23/403971.aspx. When I use...
6
by: matt | last post by:
hello, i am having trouble doing something. when a user triggers a certain event in my app, i need to initiate another web request to one of my other webpages, programmatically. currently, i do...
2
by: soul_chicken | last post by:
I'm working on a simple image upload project using the asp:FileUpload control. I read the file in and stick it into a clients content management system. The problem is that once I redirect back to...
0
by: Stan SR | last post by:
Hi, I use a repeater that calls a page where I display an image (sorry for my english ;) ) This page performs a webRequest to capture a jpg file And with the result I resize the picture and...
4
by: Supremelink | last post by:
Hi all, I have a (in my opinion) strange problem. I created an application that are extracting exchange rates from a web page and then inserts those in a ms sql database. When I´m running...
2
by: Ken Fine | last post by:
I have a question about ASP.NET output caching. I want to use screen scraping as a temporary hack to pull in some complex Classic ASP-rendered content into some ASP.NET pages: protected String...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.