Rackspace Cloud rewrite jpg causes Session reset
- by willoller
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="Redirect" redirectType="SeeOther" 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.
Things I have tried
(From the Rackspace doc 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.