# Avoid plex cache for directory items?

**URL:** <https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515>\
**Category:** Dev/API Corner\
**Tags:** plugin-dev\
**Created:** [August 22, 2014, 2:13am UTC](https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515 "2014-08-22T02:13:52Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stormwave](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Stormwave](https://forums.plex.tv/u/Stormwave)\
**Post date:** [August 22, 2014, 2:13am UTC](https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515/1 "2014-08-22T02:13:52Z")

</div>

I'm modifying a channel at the minute, and I'm trying to add a "Recently Watched" section to it using Dict items. The only problem is, Plex appears to be caching the directory item for the watched object, and thus not running my code to add the object in (if the object has already been loaded once before). In other words, the "Recently Watched" only works for new items, and completely ignores previous items as Plex is not running my code.

&nbsp;

I can work around this by adding a "time" variable into the Callback function. For example, Key = Callback(Function, time=time.time()). This tricks Plex into thinking that it is a new item, and allows my code to run. Is this workaround bad? Or reasonable? Since Plex caches the HTML retrieved anyway (I presume), the only potential delay is in processing the code itself right?

---

<div class="post-metadata">

**Author:** ![sander1](https://avatars.discourse-cdn.com/v4/letter/s/4bbf92/32.png) [@sander1](https://forums.plex.tv/u/sander1)\
**Post date:** [August 22, 2014, 11:10am UTC](https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515/2 "2014-08-22T11:10:50Z")

</div>

You should be able to prevent this by setting no\_cache=True on the&nbsp;ObjectContainer:

```
oc = ObjectContainer(no_cache=True)
```

---

<div class="post-metadata">

**Author:** ![Stormwave](https://avatars.discourse-cdn.com/v4/letter/s/8c91f0/32.png) [@Stormwave](https://forums.plex.tv/u/Stormwave)\
**Post date:** [August 23, 2014, 10:09am UTC](https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515/3 "2014-08-23T10:09:04Z")

</div>

> You should be able to prevent this by setting no\_cache=True on the&nbsp;ObjectContainer:
> 
> ```
> oc = ObjectContainer(no_cache=True)
> ```

Ah great, thanks.

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/plex/original/3X/2/a/2acb9765406f63293d357b4ec509ec39aa28f2ad.png) [@system](https://forums.plex.tv/u/system)\
**Post date:** [December 21, 2019, 2:48am UTC](https://forums.plex.tv/t/avoid-plex-cache-for-directory-items/74515/4 "2019-12-21T02:48:05Z")

</div>

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.
