locked
Prevent Internet Explorer caching of text/xml responses from ASP.Net application RRS feed

  • Question

  • I am experiencing the following problem:
    We have an ASP.Net 4.0 application hosted on an IIS 7.5 instance.
    The ASP.Net application is returning XML responses with MIME type 
    text/xml.
    We would like to avoid browser caching of these responses from Internet Explorer. The reason for this is to avoid flooding the disk with cache files (has proved to be a problem) as a large number of requests are made towards the ASP.Net application. Also it does not make sense to cache these XML responses as each response will differ from the previous.

    For text/html responses it appears setting the HTTP response header Cache-Control = no-cache prevents local caching by Internet Explorer, however for text/xml adding Cache-Control = no-cache to the HTTP response header does not appear to have any effect. Adding Cache-Control = no-store to the HTTP header does not appear to work either. Testing have been performed for IE9 and IE11 with the same result.

    Does anyone know if it is simply a limitation of IE that text/xml caching cannot be prevented? If so any suggested workarounds will be much appreciated.

    Friday, May 29, 2015 12:18 PM

All replies

  • Hi,

    is this only happening in your development environment? Turn on the Networking tab of developer tools to force refreshing from the server while the dev tools are displayed.

    are you adding a timestamp parameter to the querystring so that each request is unique?

    Post questions about html, css and scripting for website developers to http://stackoverflow.com. If possible include with your questions a link to your website or a mashup that shows the issue.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us

    Regards.


    Rob^_^

    Saturday, May 30, 2015 2:02 AM
  • Thanks for replying Rob.

    This problem has been observed in noth development environments as well as production environments. It is quite easy to reproduce actually:
    Setup a simple IIS site and apply Cache-Control=no-cache to the HTTP response header.
    When requesting text/html data (for example an html file) the no-cache directive is respected by Internet Explorer, when requesting text/xml data (for example an xml file) the no-cache directive is not respected by Internet Explorer: The XML file will be cached in the IE cache folder on disk which is what we need to prevent since there is no automatic cleanup of this folder and the folder will quickly be flooded with millions of cache files (which the file system is not able to handle properly).

    As for your other questions:

    Q: are you adding a timestamp parameter to the querystring so that each request is unique?

    A: No, each query string is not unique. To my knowledge uniqueness of the query string does not prevent caching, it only ensure that the request will be forwarded to the web server rather than IE using the local IE cache to process the request.

    Q: Post questions about html, css and scripting for website developers to http://stackoverflow.com. If possible include with your questions a link to your website or a mashup that shows the issue.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us

    A: This question is already on StackOverflow. However, so far no proposed solutions or remarks over there either. I might try http://answers.microsoft.com instead.

    So to sum up we are still no closer to a solution for this.

    If possible it would be really nice to get an official Microsoft reply regarding the original question:

    Is it simply a limitation of IE that text/xml caching cannot be prevented by applying Cache-Control=no-cache to the HTTP response header? Or by using some other procedure?

    Thanks in advance.

    Monday, June 1, 2015 12:26 PM
  • Thanks for replying Rob.

    This problem has been observed in noth development environments as well as production environments. It is quite easy to reproduce actually:
    Setup a simple IIS site and apply Cache-Control=no-cache to the HTTP response header.
    When requesting text/html data (for example an html file) the no-cache directive is respected by Internet Explorer, when requesting text/xml data (for example an xml file) the no-cache directive is not respected by Internet Explorer: The XML file will be cached in the IE cache folder on disk which is what we need to prevent since there is no automatic cleanup of this folder and the folder will quickly be flooded with millions of cache files (which the file system is not able to handle properly).

    As for your other questions:

    Q: are you adding a timestamp parameter to the querystring so that each request is unique?

    A: No, each query string is not unique. To my knowledge uniqueness of the query string does not prevent caching, it only ensure that the request will be forwarded to the web server rather than IE using the local IE cache to process the request.

    Q: Post questions about html, css and scripting for website developers to http://stackoverflow.com. If possible include with your questions a link to your website or a mashup that shows the issue.

    Questions regarding Internet Explorer 8, 9 and 10 and Internet Explorer 11 for the IT Pro Audience. Topics covered are: Installation, Deployment, Configuration, Security, Group Policy, Management questions. If you are a consumer looking for answers or to raise a question, it's highly recommended you head on over to http://answers.microsoft.com/en-us

    A: This question is already on StackOverflow. However, so far no proposed solutions or remarks over there either. I might try http://answers.microsoft.com instead.

    So to sum up we are still no closer to a solution for this.

    If possible it would be really nice to get an official Microsoft reply regarding the original question:

    Is it simply a limitation of IE that text/xml caching cannot be prevented by applying Cache-Control=no-cache to the HTTP response header? Or by using some other procedure?

    Thanks in advance.

    A: This question is already on StackOverflow. However, so far no proposed solutions or remarks over there either.

    Please include a link to your website or a publicly accessible mashup with your questions (<sic> we can read code better than we can minds</sic>).


    Rob^_^

    Tuesday, June 2, 2015 12:56 AM