Developer forum

Forum » Feature requests » Proper Etag-header on images from getimage.ashx for CDN usage

Proper Etag-header on images from getimage.ashx for CDN usage

Kevin Steffer
Kevin Steffer
Reply

Hi we have an issue with using CDN on top of getimage.ashx URL's.

Issue: Images are not updated in the CDN

We have a suspect and that is the Etag header. When the image is modified the Etag-header doesn't change, because the Etag checksum is built only taking parameters into the checksum.

Inside the Dynamicweb.ImageHandling.ConvertParameteres.vb class there's a GetHash

inputStr = Base.ChkString(CacheFolder)

If Not IsNothing(FileData) Then
    inputStr &= FileData.ToString()
End If

inputStr &= Base.ChkString(SourceFile)
inputStr &= Base.ChkString(TargetFile)
inputStr &= Format.ToString()
inputStr &= Width.ToString()
inputStr &= Height.ToString()
inputStr &= Resolution.ToString()
inputStr &= Quality.ToString()
inputStr &= ColorDepth.ToString()
inputStr &= ColorMode.ToString()
inputStr &= CropMode.ToString()
inputStr &= DoNotResize.ToString()
inputStr &= ColorTranslator.ToHtml(BackgroundColor)

_hash = Base.MD5HashToString(inputStr)

Since the "FileData" is empty as far as I can trace back.

We'd need a LastModified into that hash

inputStr = Base.ChkString(CacheFolder)

If Not IsNothing(FileData) Then
    inputStr &= FileData.ToString()
End If

inputStr &= Base.ChkString(SourceFile)
inputStr &= Base.ChkString(TargetFile)
inputStr &= Format.ToString()
inputStr &= Width.ToString()
inputStr &= Height.ToString()
inputStr &= Resolution.ToString()
inputStr &= Quality.ToString()
inputStr &= ColorDepth.ToString()
inputStr &= ColorMode.ToString()
inputStr &= CropMode.ToString()
inputStr &= DoNotResize.ToString()
inputStr &= ColorTranslator.ToHtml(BackgroundColor)

Dim fInfo As IO.FileInfo = New IO.FileInfo(SourceFile)
inputStr &= fInfo.LastWriteTime.ToFileTime().ToString()

_hash = Base.MD5HashToString(inputStr)

Replies

 
Nicolai Pedersen
Reply

TFS#31473 (8.9.2 + 9.?)

This change would create a new temp file for every change you make to the image since it also uses the hash, and that would potentially clutter up the cache folder. But anyways, did it almost like this!

Thanks for sharing.

BR Nicolai