0

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?

5
  • 1
    Is there a reason why you need to burn the entire cache? May 18 '21 at 2:14
  • 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?
    – Andy
    May 18 '21 at 9:45
  • @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? May 19 '21 at 23:00
  • 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?
    – Andy
    May 20 '21 at 8:24
  • 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.
    – Andy
    May 20 '21 at 8:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.