Published on

Sitefinity serving old versions of files

Authors

This one came though my drift today, thought I’d share the “why”

Problem

When I click a file link, sitefinity serves me the old version, not the updated one

Why it’s happening

So the good news, is this isn’t a Sitefinity problem at all; it’s a browser issue.  When a file is requested the browser uses the FULL url as the cache key.  So subsequent downloads just serve up the local file instead of having to get it again.

So if you clear your browser cache, you get the file again because there’s nothing locally to grab it from.  Now telling all your users to clear their cache is not an option (because users).  The fix is to somehow change that cache key (url) in some way to FORCE the new file.

Resolution

Lets use this as the example url

/docs/default/myfile.pdf

It’s a nice clean url, you probably just pasted it into a content block link right?  This is a cache nightmare and should be avoided.

Instead you should be using the SF Document picker to physically choose the file.  The doc picker automatically adds a cache busting querystring value to the end, and any time that file gets updated through the backend UI, that version code changes and users are served the server version, not their local cached version!

/docs/default/myfile.pdf?sfvrn=3249uf09_2

You can change it yourself though too, however it changes *doesnt matter*

/docs/default/myfile.pdf?huh=thisworks
/docs/default/myfile.pdf?lol=rofl&busting=makesmefeelgood

Kinda get the idea?  You can do it by hand every time the file changes, or just let SF handle it for you.

In the case of the issue the user had though, they were physically changing the sitefinity file in /App_Data/Storage, not using the SF UI.  Which means SF isn’t informed on the database side anything has been updated so all the version codes throughout the site didn’t change, even though they were linked properly.

In that case, a custom widget where you could manually bust the cache, or some simple jquery to find the file (or files) and append something unique on every load.

Like this

Boost your online presence.

Let us create the perfect digital experience for your company.

Contact us now