Response neobshauje contnet-length, ako to napravit?

MKI-Miro
Člen | 261
+
0
-

Ahojte

Neviem preco ale response neobsahuje content-length:

HTTP/1.1 200 OK
Server: openresty
Date: Wed, 02 Jan 2019 21:19:21 GMT
Content-Type: text/html; charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: Nette Framework
X-Frame-Options: SAMEORIGIN
Expires: Thu, 19 Nov 1981 08:52:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Pragma: no-cache
Vary: X-Requested-With,Accept-Encoding
Content-Encoding: gzip
Set-Cookie: PHPSESSID=0fe93616f30531be26e89520465c13d8; expires=Wed, 16-Jan-2019 21:19:21 GMT; Max-Age=1209600; path=/; HttpOnly

preco a ako to opravit?

Dakujem

David Matějka
Moderator | 6445
+
+2
-

na co to tam potrebujes? dynamicky generovane stranky vetsinou content-length neobsahuji (musel bys bufferovat cely vystup, nez bys ho odeslal do prohlizece)

MKI-Miro
Člen | 261
+
0
-

Chcem totiz pouzit keyCDN a nedari sa mi to, pricom v dokumentacii maju napisane

Why do my files not get cached? Why is my miss ratio high?

Please check if you’re sending the HTTP header Content-length from your origin server. The Content-length header must be both present and contain a value greater than 0 in order to produce a cache HIT. Otherwise, it will be a cache MISS.
Milo
Nette Core | 1283
+
0
-

Důvod je ten, jak píše @DavidMatějka. Šablona se prostě začne renderovat až na poslední chvíli a není jasné, jak dlouhý obsah bude. Dělá to Nette\Application\Responses\TextResponse.

Můžeš přetížit metodu Nette\Application\UI\Presenter::run(), tam TextResponse zachytit, vykreslit, spočítat si velikost výstupu a vrátit vlastní response, která hlavičku Content-Length nastaví.

David Matějka
Moderator | 6445
+
+1
-

plus jeste muze byt problem s gzipovanim obsahu, dle nejakych diskuzi na internetu nginx dropne hlavicku content-length, pokud gzipuje obsah. takze budes muset googlit a konfigurovat :))