I’ve got Drupal 7.x website and after setting-up Cloudflare there is a problem on mobile devices (tested on iPhone, but same problem is on Android devices; desktop browsers somehow manage this problem and can download PDF properly even without Content-Length) with PDF files served via Drupal aliases. After “Pause” on CF everything works fine, so it looks like this issue is CF related, not Drupal.
For some reason CF cuts out “Content-Length” for these URLs.
> curl -I https://mahajana.net/teksty/zazen-kodo-sawaki.pdf
doesn’t return “Content-lenght” in HTTP headers…
…but bypassing CF and going directly to server’s IP returns proper header:
> curl -I --resolve mahajana.net:443:18.104.22.168 https://mahajana.net/teksty/zazen-kodo-sawaki.pdf
I’ve tried to turnoff all CF features and also set-up some page rules, but no result, same problem:
Disable Security, Disable Zaraz, Disable Apps, Disable Performance
Cache Level: Bypass
Thank you, but unfortunately it’s not this and adding ‘no-transform’ doesn’t help.
Strange testing your pdf at https://tools.keycdn.com/curl content-length header only shows for gzip tests
date: Thu, 26 Oct 2023 17:42:34 GMT
cache-control: public, max-age=14400, no-transform
expires: Sun, 19 Nov 1978 05:00:00 GMT
strict-transport-security: max-age=15552000; includeSubDomains
last-modified: Thu, 26 Oct 2023 17:27:44 GMT
wonder if it's related to `x-drupal-cache` ? If you disable Drupal cache, how does it fair?
Doesn’t that show that in-flight compression by Cloudflare is the reason? If the origin delivers gzip, and then Cloudflare delivers gzip to you, then the file size is known and can be given. If the origin delivers gzip but the browser asks for brotli, or non-compressed, then the change by on-the-fly compression/decompression means the file size is unknown at the time the headers are produced.
Wow, thank you so much! I don’t get exactly why it’s a problem, but I’ve switched off Drupal’s cache and it works!
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.