Error messages related to the media cache may occur in Sitecore log files in various scenarios, such as:
The following errors can occur:
ERROR OpenFileStream failed: C:\inetpub\wwwroot\sc660rev130111WebApi\Website\App_Data\MediaCache\website\202\6f9ce455d0cc4e6f8a2d2862c016e8b8.jpg Exception: System.IO.IOException
Message: The process cannot access the file 'C:\inetpub\wwwroot\sc660rev130111WebApi\Website\App_Data\MediaCache\website\202\6f9ce455d0cc4e6f8a2d2862c016e8b8.jpg' because it is being used by another process. Source: mscorlib at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath) at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy) at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share) at Sitecore.IO.FileUtil.OpenFileStream(String filePath, FileMode mode, FileAccess access, FileShare share, Boolean createFolder, Boolean logErrors)
ERROR Could not add media to cache. Media item id: {C9276AE7-7ABB-47B0-8C26-99F669A52CF5} Exception: System.InvalidOperationException
Message: Could not create the buffer file needed for stream sharing. Source: Sitecore.Kernel
at Sitecore.IO.StreamSharer..ctor(Stream masterStream, String bufferFilePath) at Sitecore.Resources.Media.MediaCacheRecord.Initialize(Media sitecoreMedia, MediaOptions mediaOptions, MediaStream mediaStream) at Sitecore.Resources.Media.MediaCache.CreateCacheRecord(Media media, MediaOptions options, MediaStream stream) at Sitecore.Resources.Media.MediaCache.AddStream(Media media, MediaOptions options, MediaStream stream, MediaStream& cachedStream) at Sitecore.Resources.Media.Media.AddStreamToCache(MediaOptions options, MediaStream mediaStream, MediaStream& cachedStream)
This issue does not affect the site's functionality for the end users. Corresponding media requests will be processed properly, bypassing the Sitecore file-based media cache and transferring media data directly from the database.
For the antivirus scenario, it is recommended to configure the antivirus to ignore file system updates in the \App_Data\MediaCache folder.