# Clear Onebox Cache

**URL:** https://meta.discourse.org/t/clear-onebox-cache/40080
**Category:** Development
**Created:** [February 24, 2016, 8:36am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080 "2016-02-24T08:36:57Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 24, 2016, 8:36am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/1 "2016-02-24T08:36:57Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![codinghorror](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/codinghorror/32/110067_2.png) [@codinghorror](https://meta.discourse.org/u/codinghorror)
#### Post date: [February 24, 2016, 9:26am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/2 "2016-02-24T09:26:10Z")

</div>

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

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 24, 2016, 9:31am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/3 "2016-02-24T09:31:53Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 24, 2016, 9:37am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/4 "2016-02-24T09:37:56Z")

</div>

> [@fefrei](#):
>
> Is there a way to really purge this cache?

There’s always the 💣 option to `redis-cli flushall`.

> [@fefrei](#):
>
> Does it expire eventually?

Yup, it’ll automatically expire after 24 hours.

---

<div class="post-metadata">

### Author: ![fefrei](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/fefrei/32/119538_2.png) [@fefrei](https://meta.discourse.org/u/fefrei)
#### Post date: [February 24, 2016, 9:40am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/5 "2016-02-24T09:40:18Z")

</div>

Great – this helps a lot. Thanks!

💣 _all_ the caches!

---

<div class="post-metadata">

### Author: ![zogstrip](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/zogstrip/32/512781_2.png) [@zogstrip](https://meta.discourse.org/u/zogstrip)
#### Post date: [February 24, 2016, 9:41am UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/6 "2016-02-24T09:41:12Z")

</div>

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

---

<div class="post-metadata">

### Author: ![mcdanlj](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/mcdanlj/32/131829_2.png) [@mcdanlj](https://meta.discourse.org/u/mcdanlj)
#### Post date: [January 18, 2021, 6:32pm UTC](https://meta.discourse.org/t/clear-onebox-cache/40080/7 "2021-01-18T18:32:03Z")

</div>

In the redis cli, you can also delete individual keys without flushing the entire redis cache:

```plaintext
# ./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)

```

I expect that this key schema is unlikely to change often, but if it does, you can just use `keys *onebox*url*` or even `keys *url*` to look for the cached key to delete…

I can confirm that I successfully deleted cached oneboxes and rebuilt HTML for posts affected by cached broken data using this method.
