This may be the .NET version of this question.
I have an image script with the following:
...
Response.WriteFile(filename);
Response.End();
I am rewriting .jpg files using the following rewrite rule in web.config
:
<rule name="Image Redirect" stopProcessing="true">
<match url="^product-images/(.*).jpg" />
<conditions>
<add input="{REQUEST_URI}" pattern="\.(jp?g|JP?G)$" />
</conditions>
<action type="Rewrite" url="/product-images/ProductImage.aspx?path=product-images/{tolower:{R:1}}.jpg" />
</rule>
It basically just rewrites the image path into a query parameter.
The problem is that (intermittently of course) Mosso returns a new ASP Session cookie which breaks the whole world.
- Directly accessing a static .jpg file does not cause this problem.
- Directly accessing the image script does not cause it either.
- Only rewriting a .jpg file to the .aspx script causes the session loss.
It's not a redirect loop - the image appears, but the cache server submits a new session cookie, which (because it's coming from my hostname) causes the session to reset.
Things I have tried
(From the Rackspace documentation How can I bypass the cache?)
I added Private
cacheability to the image script itself:
Response.Cache.SetCacheability(HttpCacheability.Private);
I tried adding these cache-disabling nodes to web.config:
<staticContent>
<clientCache cacheControlMode="DisableCache" />
</staticContent>
and
<httpProtocol>
<customHeaders>
<add name="Cache-Control private" value="Cache-Control private"
</customHeaders>
</httpProtocol>
The Solution I need
The browser cache cannot be disabled. This means potential solutions involving Cache.SetNoStore()
or HttpCacheability.NoCache
will not work.
Alternately...
Please tell me why this is impossible to fix.