I am using Grails 2.4.4 with the Cache Headers Plugin.
Here is the tag I use:
withCacheHeaders {
etag {
"${objectType}-${lastModifiedDateTime}-${width}-${objectId}".encodeAsSHA1()
}
delegate.lastModified {
lastModifiedDate ?: 0
}
generate {
response.setContentType(ImageService.getMimeTypeFromFileName(fullFileName))
response.setHeader("Content-disposition", "filename=\"${fullFileName}\"")
response.setContentLength(imageBytes?.size())
response.outputStream << imageBytes
}
} // end withCacheHeaders
t works fine but it turns out that the response headers I set are not part of the response. They were perfectly set when I do not use the plugin.
Here are the headers which are set:
The headers which are not set are the one declared with:
response.setContentType(ImageService.getMimeTypeFromFileName(fullFileName))
response.setHeader("Content-disposition", "filename=\"${fullFileName}\"")
response.setContentLength(imageBytes?.size())
I.e., mime type, file name, content length.
How to set Response Headers with Grails CacheHeaders Plugin?
The reason why these headers do not get set is by design. Not design of the plugin but HTTP. According to RFC2616 content-type and content-length headers should not be sent with HTTP response status of 304.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments