[Cache] Serving Broken Images - Partial Content Range Cached

Karl

Active Member
#1
Hi,

Since 5.1.13 (and in 5.1.14) we're seeing Litespeed occasionally serve broken images. We've tracked this down to it serving a partial content range to clients - I am guessing this is because the initial requestor of the image, called it in multiple parts for whatever reason and the last content range called for is getting cached as the full image.

Broken image:
Code:
content-length:75366
content-range:bytes 4096-79461/79462
Working image with cache turned off:
Code:
content-length:79462
The clients showing a broken image were not requesting a partial content range at all. We've had to disable the cache as it's causing too many issues with broken images - it may happen with other content, but we're only using it for a few million images.

Thanks,

Karl
 

Karl

Active Member
#3
We'll beg to differ on that :)
Code:
x-litespeed-cache:hit
Not a lot I can tell you other than Litespeed Cache is set to cache to a RAM disk, only cache objects up to 128k in size, in the public cache, and cache requests with query strings.

These images are generated dynamically, so they are cached for speed.

If we disable the Litespeed Cache, there are no issues with only partial content-range being served. We've always seen the odd one or two instances of this happening but it's been quite rare and difficult for us to pin down, but since 5.1.13 it has got worse and a lot worse in 5.1.14 which made it quite easy to work out what was going on.
 

mistwang

LiteSpeed Staff
#4
Are you using rewrite rule to control lscache?
You should add a rewrite condition to test for content-range request header, do not enable cache if present.
 

Karl

Active Member
#5
Okay, that's not a problem, we can do that - but surely it's a bug if LS is returning partial content for a client that isn't making any (let alone the same) content-range request?

Yes, we're using a RewriteRule with [P,L,E=Cache-Control:max-age=3600]
 

mistwang

LiteSpeed Staff
#6
but surely it's a bug if LS is returning partial content for a client that isn't making any (let alone the same) content-range request?
That's something we need to take care of. is the range request got 206 status code from PHP, or 200?
If it is 206, we could avoid caching it.
 

Karl

Active Member
#7
Unfortunately I can't answer that exactly, I can see 206 responses in the logs. But I can't tell you if the original request that generated the cached image was a 206 response or not.
 

Karl

Active Member
#9
Yes, I've checked on several, a 206 response is returned on the first request the image not in the cache with a content-range. All clients then get a broken image as the partial image is cached and returned to them.
 
Top