<p>I have a large website that various users need to upload important documents (assets) to frequently.  I need to have the Craft asset cache clear every time a new asset is uploaded.  The other option I've been working through is setting a server side task to clear the cache through the command line every day at 3am.</p>
<p>Is there a way to set the Craft asset cache to clear every time a new asset is uploaded?</p>

CC BY-SA 4.0
2021-05-18T02:14:05.537Z
Is there a reason why you need to burn the entire cache?
RitterKnight
CC BY-SA 4.0
2021-05-18T09:45:21.250Z
Agree with RitterKnight here, blatting the whole asset cache seems like a drastic course of action. What symptoms are you seeing that makes you think you need to clear the Craft asset cache rather than say setting expiry headers in Apache/nginx?
Wallace
CC BY-SA 4.0
2021-05-19T23:00:33.443Z
@Andy users upload important legal documentation to the website in large batches.  These documents need to be accessible to the public ASAP.  These batches can sometimes number in the hundreds.  These documents are often just changed, not totally new, so the asset cache needs to be wiped.  Could I wipe just a specific folder?
JJefferyDev
CC BY-SA 4.0
2021-05-20T08:24:36.023Z
That to me is more of a browser caching thing. Are the filenames/paths remaining the same? I assume that you're being served, or the browser is re-displaying a cached document that you know has changed? Is this repeatable across browsers which have never downloaded the asset? 
Perhaps yould you set expire headers for a particular document type or path pattern?
Wallace
CC BY-SA 4.0
2021-05-20T08:24:57.050Z
As a related aside to this, I'd question the validity of updating just the content of a document especially if it's something legal. I've always encouraged clients to include versioning in the filename so it's easy to identify once downloaded.
Wallace
<craft3><assets><cache>
Automatic Asset Cache Clear
# Automatic Asset Cache Clear

(Asked by: username_0 on 2021-05-17)

I have a large website that various users need to upload important documents (assets) to frequently. I need to have the Craft asset cache clear every time a new asset is uploaded. The other option I've been working through is setting a server side task to clear the cache through the command line every day at 3am.

Is there a way to set the Craft asset cache to clear every time a new asset is uploaded?

**Tags:** craft3, assets, cache
> **Comments:**
> **username_1**: Is there a reason why you need to burn the entire cache?  
> **username_2**: Agree with RitterKnight here, blatting the whole asset cache seems like a drastic course of action. What symptoms are you seeing that makes you think you need to clear the Craft asset cache rather than say setting expiry headers in Apache/nginx?  
> **username_0**: @Andy users upload important legal documentation to the website in large batches.  These documents need to be accessible to the public ASAP.  These batches can sometimes number in the hundreds.  These documents are often just changed, not totally new, so the asset cache needs to be wiped.  Could I wipe just a specific folder?  
> **username_2**: That to me is more of a browser caching thing. Are the filenames/paths remaining the same? I assume that you're being served, or the browser is re-displaying a cached document that you know has changed? Is this repeatable across browsers which have never downloaded the asset?  Perhaps yould you set expire headers for a particular document type or path pattern?  
> **username_2**: As a related aside to this, I'd question the validity of updating just the content of a document especially if it's something legal. I've always encouraged clients to include versioning in the filename so it's easy to identify once downloaded.  

---

## 0 answers

