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 |
![]() |
---|---|
<se:cachefile maxage="00:00:30" localid="cacheit" transfer="false" /> {buffer.set(w, request.query(w, default=400))} {scope.cacheit.key.add(w, $w)} {scope.cacheit.serve()} <se:image location="/assets/images/ng/PhotographybyBrianSkerry1.jpg" width="{buffer.get(w)}" resulttype="binary" filetype="jpg" jpgquality="95" resultformat="{this.setforcedresult(this.result(binary), 'image/jpeg', false)}" /> |
Example Result |
![]() |
---|---|
(Resized Image) |