1

I have simple caching problem: I have old "name.jpg", then customer uploads new "name.jpg" and clients dont see any changes, for them its still cached old "name.jpg".

I know how to turn off caching, but its not good decision, so I try to find better.

So question is:

How does caching work if I add get parameter after question mark?

For example I have url

http://example.com/name.jpg?cache_time=111

And then I replace it to

http://example.com/name.jpg?cache_time=222

Will it download second name.jpg and replace existing or not? I know its work with css or js files in browser, but know nothing about glide behaviour.

Zoe
  • 27,060
  • 21
  • 118
  • 148
Andrey Danilov
  • 6,194
  • 5
  • 32
  • 56
  • 1
    You might want to look at the `signature()` method of the Glide request builders. It allows you to add your own data used for invalidating. From their javadoc: Sets some additional data to be mixed in to the memory and disk cache keys allowing the caller more control over when cached data is invalidated. Note - The signature does not replace the cache key, it is purely additive. – cwbowron Sep 07 '17 at 12:04

1 Answers1

1

Whatever parameters you pass in the url query will be sent to the server serving the image and only if that server handles that exact parameter (cache_time) can there be any difference in behavior.

The caching glide does however is not based on what you send to the server, but rather on the configuration you give to glide.

I suggest you look up how glide handles caching, and perhaps manually invalidate the cache for a specific image when you know it has changed.

This is a good place to start: Remove image from cache in Glide library. It also has examples how to use signature()that is mentioned in the comment above.

Tim
  • 41,901
  • 18
  • 127
  • 145