How do I replace an image in assets and keep the url without version

I saw this thread and am wondering if I’m doing something wrong?

It says that reuploading a file with the same filename will replace the existing version at the same URL, but it doesn’t seem to be doing that for me, or at least not working as I hoped.

But when I try to reupload/replace an image the base url is still the original in some places where I try to load it, I thought it might be a cache issue, but clearing cache and also opening the file on my work laptop it’s still the old version. When I wrote this thread, the url alone gave an updated image in the preview, but adding [img][/img] tags reverted it to the original version. Is the issue that I’m trying to embed or share the file externally?
https://cdn.glitch.com/4e186ba1-294e-41c8-8ead-e5ae4e16233e%2Fimage.png


vs
https://cdn.glitch.com/4e186ba1-294e-41c8-8ead-e5ae4e16233e%2Fimage.png?v=1610735158936

I’m very new to glitch, so sorry if this is a simple or repetitive question, but could not for the life of me find an answer when searching.

Thank you so much, any insight is appreciated!

[edit] A web dev friend recommended I try appending ?clear_transients and that seems work, but if anybody has anything to add, I’m all ears!

It still sounds like you’re having a cache issue. Did you clear the cache for your *.glitch.me domain or for cdn.glitch.com? Because the assets are served from a different origin than your Glitch site, clearing your Glitch project’s cache doesn’t actually clear the assets from the cache.

The ?v=....... at the end of an asset url is just a cache buster. It’s updated in the Glitch editor everytime you upload a new version as a convenience but in reality you can put any string after the ? and it’ll serve the same purpose. Browsers cache based on the URL, if it sees the same url it assumes it’s safe to use the cached version. The Glitch CDN ignores all URL parameters so that you can use them to ensure browsers always re-fetch the latest version (this is why your friend’s suggestion worked).

The tricky thing you’re struggling with is that if a browser has cached example.com/image.png?v=1 it’ll likely serve that cached version for example.com/image.png even though it’s a different URL because it’s the base of a cached URL. However example.com/image.png?v=2 is treated as a new URL and requested from the server not the cache.

Just wanted to add that this can sometimes be a bad thing. I use Cloudflare for my website and once people where able to bypass it and get to the origin server by appending a random query string to the end. Requests looked something like:

GET /?jskdjfhdsljafhssdfjhuewh9f8uwfilkhsaldkfjasjdf

This meant that it was possible to DDoS and get around Cloudflare (I’ve since tweaked Cloudflare’s settings so this isn’t an issue anymore :sweat_smile:

oops i typed up a response and never hit send.

Thanks for the replies! I thought I cleared the cache for everything from the previous 24 hours, but it’s possible there’s something more I need to do. Had no idea that the v=### query was just for getting around caches, learned something new!

I might do more digging on how CDNs actually work because it’s very black-box-y to me.