Cached dynamic image serving Example

In this example, we want to serve dynamically scaled images but keep cache for each image width as passed over the querystring.

Note that the key aspect to this case is to set the transfer parameter to false, then add the cachekey dependencies.

Smartsite SXML CopyCode image Copy Code
<se:cachefile maxage="00:00:30" localid="cacheit" transfer="false" />
{buffer.set(w, request.query(w, default=400))}
{scope.cacheit.key.add(w, $w)}

<se:image location="/assets/images/ng/PhotographybyBrianSkerry1.jpg" 
    width="{buffer.get(w)}" resulttype="binary" filetype="jpg" 
    resultformat="{this.setforcedresult(this.result(binary), 'image/jpeg', false)}"
Example Result CopyCode image Copy Code
(Resized Image)