Note that there are some explanatory texts on larger screens.

plurals
  1. POcaching trouble: dynamic css files
    primarykey
    data
    text
    <p>I have some css files that need to be generated dynamically (why is complicated, but it's necessary). The easy solution is to change the files to aspx files, and use &lt;%= %> tags as needed to inject the values I want. </p> <p>This works fine, until we get to caching. It seems that the browser and server refuse to cache the file. I've tried manipulating the various http cache headers, but the browser always re-gets the file on each page load. The server always responds with HTTP 200 (and the correct content), rather than with a 304 (file unchanged). </p> <p>How can I convince the browser and the server to cache these dynamic css files?</p> <p>Example consuming file:</p> <blockquote> <p><code>&lt;html&gt; &lt;head&gt; &lt;link href="/style.aspx" type="text/css" rel="stylesheet"/&gt;</code> ...</p> </blockquote> <p>Example style sheet, with cache header manipulation (omitting dynamic part of file):</p> <blockquote> <p><code>&lt;%@ Page Language="C#" ContentType="text/css" EnableSessionState="False" %&gt;</code><br> <code>&lt;%</code> <code>Response.Cache.SetLastModified(new DateTime(2009, 11, 18, 10, 1, 0));</code> <code>Response.Cache.SetMaxAge(TimeSpan.FromDays(30));</code> <code>Response.Cache.SetETag("4ffff353ff67ff1:0");</code> <code>%&gt;</code><br> ...css here...</p> </blockquote> <p>The request headers to the server includes the following:</p> <blockquote> <p><code>If-Modified-Since Wed, 18 Nov 2009 18:01:00 GMT</code><br> <code>Cache-Control max-age=0</code></p> </blockquote> <p>And the related server response headers are:</p> <blockquote> <p><code>Cache-Control private, max-age=2592000</code><br> <code>Last-Modified Wed, 18 Nov 2009 18:01:00 GMT</code><br> <code>Date Wed, 18 Nov 2009 19:36:07 GMT</code></p> </blockquote> <p>Any ideas?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload