Clear Onebox Cache

I’m developing a small Onebox plugin and testing it in my production install.

It appears that Discourse is caching the Oneboxes: When I paste a link I once saw oneboxed into a new post, the preview is still looking as if it was generated by an older version of the plugin, while newer links appear as they should. All this is happening in the preview, I’m not actually posting the link.

How can I clear this cache?

Adding a rando querystring is usually the best quick & dirty way.

2 „Gefällt mir“

Yes, that works – but only to circumvent the cache for testing, not to clear it for end users.

Is there a way to really purge this cache? Does it expire eventually?

There’s always the :bomb: option to redis-cli flushall.

Yup, it’ll automatically expire after 24 hours.

3 „Gefällt mir“

Great – this helps a lot. Thanks!

:bomb: all the caches!

1 „Gefällt mir“

Be aware that flushing redis will clear sidekiq’s queue (and thus might end up losing some email notifications)

6 „Gefällt mir“

In der Redis-CLI können Sie auch einzelne Schlüssel löschen, ohne den gesamten Redis-Cache zu leeren:

# ./launcher enter app
# redis-cli
> keys *CACHE:onebox*example.com*
1) `"default: CACHE:onebox__https://example.com/"`
> del "default: CACHE:onebox__https://example.com/"
(integer) 1
> keys *CACHE:onebox*example.com*
(empty list or set)

Ich gehe davon aus, dass sich dieses Schlüssel-Schema nicht häufig ändern wird. Falls doch, können Sie einfach keys *onebox*url* oder sogar keys *url* verwenden, um den zu löschenden zwischengespeicherten Schlüssel zu finden…

Ich kann bestätigen, dass ich mit dieser Methode erfolgreich zwischengespeicherte Oneboxes gelöscht und das HTML für Beiträge neu aufgebaut habe, die von fehlerhaften zwischengespeicherten Daten betroffen waren.

9 „Gefällt mir“