Placeholders cache and invalidation and plugins?

104 views
Skip to first unread message

robos85

unread,
Sep 20, 2012, 5:46:35 PM9/20/12
to djang...@googlegroups.com
Is there any way, to detect, by signals, that plugin has been changed, then get plugin placeholder id and invalidate cached content, based on placeholder id?
On some pages I have more than 200 queries because of many plugins used in placeholders. My strategy is to cache that by {% cache %} and as a key i want to use: "cache_placeholder id". But I need to detect plugin changed to invalidate it.

Thanks in advance.

Benjamin Wohlwend

unread,
Sep 21, 2012, 3:34:51 AM9/21/12
to djang...@googlegroups.com
Hi,

On Thu, Sep 20, 2012 at 11:46 PM, robos85 <weglare...@gmail.com> wrote:
> Is there any way, to detect, by signals, that plugin has been changed, then
> get plugin placeholder id and invalidate cached content, based on
> placeholder id?

You could listen on the post_save signal of CMSPlugin:

models.signals.post_save.connect(invalidate_plugin_cache, sender=CMSPlugin)

your handler receives a CMSPlugin instance with a reference to the
placeholder. Note that this doesn't work if the plugin displays data
that isn't stored in the plugin instance itself, e.g. a list of newest
blog entries.

> On some pages I have more than 200 queries because of many plugins used in
> placeholders. My strategy is to cache that by {% cache %} and as a key i
> want to use: "cache_placeholder id". But I need to detect plugin changed to
> invalidate it.

Did you try the newly released django CMS 2.3.2? We reduced queries
generated by plugins and placeholders significantly since 2.3.0, it
might solve your problems without using brittle cache mechanisms.

Kind regards,
Benjamin
Reply all
Reply to author
Forward
0 new messages