Reputation: 41
Using ImageResizer
to resize user-uploaded files on the fly.
When a file is deleted in the database (row deleted), both the original and the resized versions is still accessible for some time until the cleanup schedule is done.
In case of copyright, porn etc, is there a way to let DiskCache
know the file has been deleted and force the file to be removed from cache right away?
I am thinking it could be solved by IVirtualFileWithModifiedDate
, but wouldn’t it require to query the db on every request instead of just handling it during deletion time?
A bit like:
DAL.DeleteImage(ImageID);
DiskCachePlugin.Invalidate(ImageID);
Upvotes: 4
Views: 543
Reputation: 16468
When a file is deleted in the database (row deleted), both the original and the resized versions is still accessible for some time until the cleanup schedule is done.
ImageResizer does not permit cached versions to be accessed once it knows the original is inaccessible. That said, some providers (like Sql and S3) cache existence metadata for a sliding window (with a 1hr minimum), which could cause the behavior you're seeing. in V4, you can disable this metadata caching to ensure access is immediately revoked.
Upvotes: 1