Developer forum

Forum » Development » File and/or Image file cache updated

File and/or Image file cache updated

Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi,

 

Is there a notification I can subscribe when a new file is uploaded?

 

My use case is with customers updating product images in the backend, and because we use a CDN (Cloudflare), it doesn't get automatically updated. It's always a balance of settings in the CDN to strike an acceptable balance because of the rare occasions images change. But because customers don't see it automatically reflected (and they forget the commitment to more aggressive caching, or it's a new person in the organization that doesn't know about it), they keep asking for support. If I can get a notification of images being uploaded, we could reach out to the CDN and clear it's cache as well.

 

(this obviously wouldn't work if they use FTP or some other way to bypass DW updating the file)

 

BR

Nuno Aguiar


Replies

 
Imar Spaanjaars Dynamicweb Employee
Imar Spaanjaars
Reply

I'm not aware of any. I checked the code for some of the upload functionality and all it seems to do is save the uploaded files.

You can however write code that uses a FileSystemWatcher and handle events like Created and Deleted: https://learn.microsoft.com/en-us/dotnet/api/system.io.filesystemwatcher?view=net-9.0 That link is for .NET 9 (i.e, DW 10) but the same class exists in the .NET Framework for DW 9 and the API's haven't changed much over the years.

Imar

 
Nuno Aguiar Dynamicweb Employee
Nuno Aguiar
Reply

Hi Imar,

 

That's a good idea; just what you used when building the Optimizer. And that would work with FTP upload as well;

 

Thank you,

Nuno

 

You must be logged in to post in the forum