Why do my images or files cache?

If you are replacing images or files with something that has the same name - you may not see it change straight away - this is due to "caching".

You have two options - either rename the image or file to something completely different (or simply adding a letter or number to it eg change Homepage_image.jpg to Homepage_image_1.jpg) or to clear your cookies and cache and then wait.

How long does it take for the cache to clear?

Unfortunately no there is no real standard.

The server caches static files like images etc for up to a maximum of one day to speed things up, so anything more than that old is being cached on the client browser.  Content in a page is cached until you edit it.  There are actually 6 layers of caching that happen before your browser ever sees the file, however all of these expire in hours not days.  These are all different types of cache from your browser cache, which is the one we are talking about here.

Different browsers have different thresholds, and some can be changed by addons such as fasterfox.  Many networks employ caching proxy servers which add more layers of caching.

The most common algorithm used for determining how long to cache something is to look at its last modification date, and use that to guess how long to cache by multiplying it by some factor.  Every browser has its own rules: one example might be a cache factor of 0.1 - so if something is 10 days old, it will cache for 1 day.  100 day old items cache for 10 days, and so forth.  Since when a browser caches something it no longer asks the server for it again, there is no way to "uncache" something once it is cached.

Caching is not something you would ever want to turn off : that would make your website unconscionably slow.   The only way to 100% guarantee that everyone sees the new version of a file is to change its name every time you make major changes to it.