Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3458032
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T09:55:59+00:00 2026-05-18T09:55:59+00:00

I am using an instance of WebClient in my Silverlight application to retrieve an

  • 0

I am using an instance of WebClient in my Silverlight application to retrieve an image file for display. In order to service this application, I have set up a WCF REST service. The following is a snippet of code I wrote for that service:

DateTime modSince = WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.IfModifiedSince] 
    == null 
    ? DateTime.MinValue 
    : DateTime.Parse(WebOperationContext.Current.IncomingRequest.Headers[HttpRequestHeader.IfModifiedSince].ToString());

FileInfo fInfo = new FileInfo(filePath);

if (fInfo.LastWriteTime > modSince)
{
    WebOperationContext.Current.OutgoingResponse.ContentType = "image/jpeg";
    WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.OK;
    WebOperationContext.Current.OutgoingResponse.LastModified = fInfo.LastWriteTime;
}
else
{
    WebOperationContext.Current.OutgoingResponse.SuppressEntityBody = true;
    WebOperationContext.Current.OutgoingResponse.StatusCode = HttpStatusCode.NotModified;
}

The service is set up such that on a request for an image file, the if-modified-since attribute of the request header is examined. If this value is less than the last time the file is modified, the file is returned. Otherwise, a 304 message is returned.

We are interested in making the transaction faster. Since the images rarely, if ever, change it is desirable to look up the cache for a copy of the image before making a request to the server, which would save on network latency. In trying to implement this for IE, I have changed the Temporary Internet Files settings to “never check for newer versions of stored pages”. When I enter in the browser’s address bar the REST service URL for an image that has a copy stored in the cache, the copy is retrieved from the cache without the server being called. However, when the URL is entered as a parameter to the WebClient’s OpenReadAsync method a GET request is sent to the server, leading to a 304 message.

Is there any way I could use the WebClient to look up the cache without a GET request being sent to the server?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-18T09:56:00+00:00Added an answer on May 18, 2026 at 9:56 am

    You can’t prevent the request from code in Silverlight. The “never check” setting of IE is only used in the absence of cache control directives from the server, I would not recommend you use it.

    I’m not sure why you are using WCF Rest to deliver images to the client instead of simply placing the images in a folder on the server and fetching them as standard static content?

    Either way the correct approach to the your problem is for the server to specify how the images should be cached by including a Cache-Control header in the response. Something like “Cache-Control: max-age=86400”.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

No related questions found

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.