Skip to content

Commit

Permalink
Cache stable image scales strongly.
Browse files Browse the repository at this point in the history
When plone.app.imaging is available, this is already done.
Otherwise, we should do this ourselves.
Fixes #100.
  • Loading branch information
mauritsvanrees committed Jul 9, 2021
1 parent 7cc93b4 commit 0b0cd85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
5 changes: 5 additions & 0 deletions news/100.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
Cache stable image scales strongly.
When plone.app.imaging is available, this is already done.
Otherwise, we should do this ourselves.
Fixes `issue 100 <https://github.com/plone/plone.namedfile/issues/100>`_.
[maurits]
19 changes: 19 additions & 0 deletions plone/namedfile/scaling.zcml
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<configure
xmlns="http://namespaces.zope.org/zope"
xmlns:cache="http://namespaces.zope.org/cache"
xmlns:zcml="http://namespaces.zope.org/zcml"
xmlns:browser="http://namespaces.zope.org/browser">
<include package="zope.annotation" />
<browser:page
Expand All @@ -20,4 +22,21 @@
factory=".scaling.DefaultImageScalingFactory"
for="*"
/>

<!-- In plone.app.caching, image scales are weakly cached.
But stable (uid) image scales should be strongly cached.
When plone.app.imaging is available, this is already done.
Otherwise, we should do this ourselves.
See https://github.com/plone/plone.namedfile/issues/100 -->
<configure zcml:condition="not-installed plone.app.imaging">
<configure zcml:condition="installed z3c.caching">
<include package="z3c.caching" />
<include package="z3c.caching" file="meta.zcml" />
<cache:ruleset
for=".interfaces.IStableImageScale"
ruleset="plone.stableResource"
/>
</configure>
</configure>

</configure>

0 comments on commit 0b0cd85

Please sign in to comment.