aliostad / CacheCow

An implementation of HTTP Caching in .NET Core and 4.5.2+ for both the client and the server
MIT License
847 stars 172 forks source link

Truncate existing cache file #286

Closed LXGaming closed 1 year ago

LXGaming commented 1 year ago

This PR fixes an issue with the FileStore, When a pre-existing cache file is overwritten it isn't truncated, this can result in an updated response having remnants of previous responses on the end.

I've replaced File.OpenWrite which uses FileMode.OpenOrCreate with FileMode.Create which will truncate the file if it exists.

Microsoft Docs: System.IO.FileMode

aliostad commented 1 year ago

Thanks for supplying an important bug fix. I will release your fix soon (sorry I was away)

aliostad commented 1 year ago

I am sorry that it took a while. Version 2.11.3 has your fixes.