using gzip on my php output like this
if( isset($compression['html']) && $compression['html'] == TRUE)
{
ob_start("ob_gzhandler");
header("cache-control: must-revalidate");
header("expires: ".gmdate('D, d M Y H:i:s', time() + $compression['expire'])." GMT");
}
produces the error show in the image below. It works fine in FF and Safari, but in chrome it does not. Any idea how to solve it?
This is the header I get
Request URL:http://www:8888/formandsystem/gzo/de/dashboard
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Charset:ISO-8859-1,utf-8;q=0.7,*;q=0.3
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en-US,en;q=0.8,de;q=0.6
Cache-Control:max-age=0
Connection:keep-alive
Cookie:ci_session=kyK5%2BhpX3N6dE7v9IoZtDzNRWT8rheDQATYZ7ztAoaAhbubmwfk2eScdjoZl0Bzwfi89YSPmwERE6NZ24t%2BCCgq4ImtYsJl12Fv%2B2GmmmA%2FPiOlxULO7cBx%2B%2BMFzbLtENeENHjBc16Oxg456Nykd6AGVUe1Kjc3u0c44xyOMVB1ZVrbBXEeujoLlaxUsDl2VJE8BvkqhqvD6DjgblNnKuTT1IvJ2VONduY2tqSk0Ldo6agsdEm0hIpILjTAEGSOqPETkXHA%2FWOGR1rH0f2M4C7ARhg14Vw%2BETIuMy5I4E14OU9FZAMZBmgXj%2FlbwG4v7Pfpq3vGCGF9LJHbtyUy9JBaucjz4s34jE36XLC3Mb2f5NNHhoTjAuLlpO%2FLKrYEutjxaXjMxId4BBWQEbIaKVFaWU5f6HZ671X2lTucUXE%2BHcyjxeGXa10bYygICJu%2BfcCU54k9LJoRB%2BCPR4SIdKQ%3D%3D
Host:www:8888
Referer:http://www:8888/formandsystem/gzo/de/dashboard
User-Agent:Mozilla/5.0 (Macintosh; Intel Mac OS X 10_7_3) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11
Response Headersview source
Cache-Control:no-cache, must-revalidate
Connection:Keep-Alive
Content-Encoding:gzip
Content-Length:1855
Content-Type:text/html;charset=utf-8
Date:Fri, 09 Mar 2012 00:07:29 GMT
Expires:Fri, 09 Mar 2012 01:07:29 GMT
Keep-Alive:timeout=15, max=100
Pragma:no-cache
Server:Apache
Vary:Accept-Encoding
X-Powered-By:PHP/5.2.13
Thanks
Related
I am using wildfly-9 with java-8 on windows OS.
I have implemented changes in spring-boot to support Range with gzip compression/encoding.
consider below pseudo code code to get GZIPOutputStream from javax.servlet.ServletResponse.getOutputStream()
OutputStream gzos;
if(fileName.indexOf(".") > 0){
fileExtension = fileName.substring(fileName.lastIndexOf("."));
response.setContentType(DownloadUtil.getContentType(fileExtension));
}
String disposition = getContentDispositionParameter(request, fileName);
response.setHeader("Content-Disposition", disposition);
if(fileExtension.equalsIgnoreCase(".zip") || DownloadUtil.isGZipSuppored(request)==false || fileExtension.equalsIgnoreCase(".file")){
response.setHeader("Content-Length", String.valueOf(fileSize));
gzos = response.getOutputStream();
} else {
response.setHeader("Content-Encoding", "gzip");
gzos = new GZIPOutputStream(response.getOutputStream());
}
return new BufferedOutputStream(gzos);
Using this BufferedOutputStream object to send file's data with some other headers.
Facing issue in case of interruption while download file in chrome browser(i.e. service re-start while download file)
For initial download request
accept-encoding = gzip, deflate, br is passed while after interrupted download, when user resume download chrome browser is sending
accept-encoding = identity
Due to this I am not able to identify whether browser is supporting gzip encoding or not & So, I need to send non-gzip response.
Note: In firefox I am getting accept-encoding = gzip in Range request.
Initial request request/response header
============== Request headers===============
host=localhost:9097
connection=keep-alive
sec-ch-ua="Google Chrome";v="107", "Chromium";v="107", "Not=A?Brand";v="24"
sec-ch-ua-mobile=?0
sec-ch-ua-platform="Windows"
upgrade-insecure-requests=1
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
accept=text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
sec-fetch-site=none
sec-fetch-mode=navigate
sec-fetch-user=?1
sec-fetch-dest=document
accept-encoding=gzip, deflate, br
accept-language=en-US,en;q=0.9
============== Response headers===============
Content-Disposition=attachment;filename="24371676.txt"
Accept-Ranges=bytes
ETag=24371676.txt_43371681_1667802564570
Last-Modified=Mon, 07 Nov 2022 06:29:24 GMT
Expires=Tue, 22 Nov 2022 12:16:13 GMT
Content-Encoding=gzip
Content-Range=bytes 0-43371680/43371681
Range request(resume after interrupted download) request/response header
============== Request headers===============
host=localhost:9097
connection=keep-alive
range=bytes=10373334-
if-range=24371676.txt_43371681_1667802564570
accept-encoding=identity
sec-fetch-site=none
sec-fetch-mode=navigate
sec-fetch-dest=empty
user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36
accept-language=en-US,en;q=0.9
============== Response headers===============
Content-Disposition=attachment;filename="24371676.txt"
Accept-Ranges=bytes
ETag=24371676.txt_43371681_1667802564570
Last-Modified=Mon, 07 Nov 2022 06:29:24 GMT
Expires=Tue, 22 Nov 2022 12:17:34 GMT
Content-Range=bytes 10373334-43371680/43371681
Is there any configuration or header needs to be added So, I can get request header accept-encoding=gzip, deflate, br and I can supply gzip response in chrome.
Edit: I have also refer: Issue making range requests in some browsers and seems like there is specification is changed
i cant found the answer for my problem because i use yii2
HEADERS - General
Request URL:
https://source.myweb.com/css/icons/icomoon/css/icomoon.css Request
Method: GET Status Code: 200 Remote Address: 104.27.189.114:443
Referrer Policy: no-referrer-when-downgrade
RESPONE HEADERS
cache-control: public, max-age=604800
cf-bgj: minify
cf-cache-status: HIT
cf-polished: origSize=48769
cf-ray: 4b3f84c7adf9c388-SIN
content-encoding: br
content-type: text/css
date: Thu, 07 Mar 2019 21:03:53 GMT
expect-ct: max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"
expires: Thu, 14 Mar 2019 21:03:53 GMT
last-modified: Wed, 20 Feb 2019 15:19:22 GMT
server: cloudflare
status: 200
vary: Accept-Encoding,User-Agent
x-turbo-charged-by: LiteSpeed
REQUEST HHEADERS
Provisional headers are shown
Referer: https://blog.myweb.com/
User-Agent: Mozilla/5.0 (Linux; Android 5.0; SM-G900P Build/LRX21T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/72.0.3626.121 Mobile Safari/537.36
i was try many answer but i cant resolved this ?
I write a simple code:
<?php
echo "<h1>1233422</h1>";
?>
<html>
<img src="screen.png"/>
</html>
there is an image in the html, but when I refresh the browser page the png image is 200.
theoretically the image response status should be 304, why there is 200?
Two times request's Response Header are:
HTTP/1.1 200 OK
Content-Type: image/png
server: PhpStorm 10.0.1
date: Fri, 07 Dec 2018 03:35:42 GMT
cache-control: private, must-revalidate
last-modified: Fri, 07 Dec 2018 03:34:56 GMT
content-length: 11437
the second request Headers:
GET /test03-hante/screen.png HTTP/1.1
Host: localhost:63342
Connection: keep-alive
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_0) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36
Accept: image/webp,image/apng,image/*,*/*;q=0.8
Referer: http://localhost:63342/test03-hante/index.php
Accept-Encoding: gzip, deflate, br
Accept-Language: zh-CN,zh;q=0.9,en;q=0.8
Cookie: wp-settings-time-1=1539853185; Webstorm-b87204fd=531be1b1-a109-47c6-97d9-4dd7b886ebde
you see, there is no If-Modified-Since and If-Non-Match params, why?
In browser refresh, HTTP image response status is "200 (cache)" because in refresh the image loaded from your browser cache.
You can learn more from this answer: https://stackoverflow.com/a/1665097/6678086
I'm having serious problems with Google Chrome.
I'm using MediaElement.js for audio and video playback. Firefox seems to play everything fine, so far.
Chrome doesn't. As soon, as the file becomes bigger, it won't play.
I have two test files. Both Mp4. The first one plays well in Chrome:
Request Headers:
Accept: */*
Accept-Encoding: identity;q=1, *;q=0
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection: keep-alive
DNT: 1
Range: bytes=0-
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Response Headers:
Accept-Ranges: bytes
Cache-control: max-age=31536000, private
Connection: keep-alive
Content-disposition: attachment; filename="big_buck_bunny.mp4"
Content-Length: 5510872
Content-Type: video/mp4
Date: Mon, 24 Feb 2014 04: 13: 40 GMT
ETag: "24"
Expires: Tue, 24 Feb 2015 04: 13: 39 GMT
Last-Modified: Sat, 22 Feb 2014 16: 28: 14 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-Powered-By: PHP/5.5.9-1~dotdeb.1
X-XSS-Protection: 1; mode=block
The 2nd one doesn't:
Request Headers:
Accept: */*
Accept-Encoding: identity;q=1, *;q=0
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Cache-Control: max-age=0
Connection: keep-alive
DNT: 1
Range: bytes=0-
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Response Headers:
Accept-Ranges: bytes
Cache-control: max-age=31536000, private
Connection: keep-alive
Content-disposition: attachment; filename="test.mp4"
Content-Length: 21546967
Content-Type: video/mp4
Date: Mon, 24 Feb 2014 04: 11: 29 GMT
ETag: "31"
Expires: Tue, 24 Feb 2015 04: 11: 29 GMT
Last-Modified: Mon, 24 Feb 2014 03: 23: 48 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-Powered-By: PHP/5.5.9-1~dotdeb.1
X-XSS-Protection: 1; mode=block
On Google, i found several discussions regarding this or similar problems. However, i havent found a real solution for this problem.
Another (maybe important) info is, that i serve the files via PHP. If i use the direct URL of the file, it works:
Request Headers:
Accept: */*
Accept-Encoding: identity;q=1, *;q=0
Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4
Connection: keep-alive
DNT: 1
If-Range: "9c0c52-148c7d7-4f31e800012d1"
Range: bytes=21510441-21546966
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/33.0.1750.117 Safari/537.36
Response Headers:
Accept-Ranges: bytes
Connection: keep-alive
Content-Length: 36526
Content-Range: bytes 21510441-21546966/21546967
Date: Mon, 24 Feb 2014 04: 19: 03 GMT
ETag: "9c0c52-148c7d7-4f31e800012d1"
Last-Modified: Mon, 24 Feb 2014 03: 23: 48 GMT
Server: nginx
X-Content-Type-Options: nosniff
X-Frame-Options: sameorigin
X-XSS-Protection: 1; mode=block
I've tested several scenarios now. This seems to be a general problem. Streaming media files via PHP doesn't work properly. The only reliable way is to stream the files via webserver.
I'm new to JSONP and I'm trying to access a cross domain file hosted on my webserver.
UPDATE: I found another solution to fix my issue: I used CORS for JQUERY of http://www.html5rocks.com/en/tutorials/cors/
Here is my js file:
var url = "myip:port/pgif.jsonp?callback=?"
var url2 = "http://puppygifs.tumblr.com/api/read/json?callback=?";
$.getJSON(url2, {
tags: "jquery",
tagmode: "any",
format: "json"
}, function (data) {
console.log("d= ", data);
});
}
);
When I try with url2, it works well but when I try with url to access my file on my webserver it doesn't.
Here is what I can see in the Network tab of Chrome Dev tools with url2 which works:
Request URL:http://puppygifs.tumblr.com/api/read/json?callback=jQuery19107969533477444202_1386114768597&tags=jquery&tagmode=any&format=json&_=1386114768598
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en,fr-FR;q=0.8,fr;q=0.6
Cookie:__utma=189990958.626465526.1385955515.1385955515.1385955515.1; __utmc=189990958; __utmz=189990958.1385955515.1.1.utmcsr=sarajchipps.com|utmccn=(referral)|utmcmd=referral|utmcct=/2011/01/using-jquery-ajax-calls-in-a-chrome-plugin.html
Host:puppygifs.tumblr.com
Proxy-Authorization:Negotiate TlRMTVNTUAADAAAAGAAYAIQAAABiAWIBnAAAAAwADABYAAAAEAAQAGQAAAAQABAAdAAAABAAEAD+AQAAFYKI4gYBsR0AAAAPwICK4LzPlRZWoe1WgJ+erkYATwBYAFQARQBMAGIAYQBzAHQAaQBkAGUAZgBIAFEAMAAyADcANAAzADUAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA+t3F+qb2rUYkHj2KQg3XtAEBAAAAAAAAanrqyYLwzgG/iL4+KqlreQAAAAACAAwARgBPAFgAVABFAEwAAQAQAFMAWQBEAFQATQBHADAAMQAEACIAZQBuAHQALgBmAG8AeAB0AGUAbAAuAGMAbwBtAC4AYQB1AAMANABTAFkARABUAE0ARwAwADEALgBlAG4AdAAuAGYAbwB4AHQAZQBsAC4AYwBvAG0ALgBhAHUABQAiAGUAbgB0AC4AZgBvAHgAdABlAGwALgBjAG8AbQAuAGEAdQAHAAgAanrqyYLwzgEGAAQAAgAAAAgAMAAwAAAAAAAAAAAAAAAAIAAA+jYk8RidWxnk5XJtyRLc7j6jPZX/e7BWswB5GZeS2JYKABAAAAAAAAAAAAAAAAAAAAAAAAkAIgBIAFQAVABQAC8AMQAwAC4AMgAwAC4AMQA2AC4AMQAwADAAAAAAAAAAAAAAAAAA2S3kxHzp0FstuiERqIRwqQ==
Proxy-Connection:keep-alive
Referer:http://ip:port/MyApp/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
Query String Parametersview sourceview URL encoded
callback:jQuery19107969533477444202_1386114768597
tags:jquery
tagmode:any
format:json
_:1386114768598
Response Headersview source
Cache-Control:max-age=900
Connection:Keep-Alive
Content-Type:text/javascript
Date:Tue, 03 Dec 2013 23:52:57 GMT
Last-Modified:Sun, 03 Feb 2013 12:02:52 GMT
P3P:CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL"
Proxy-Connection:Keep-Alive
Transfer-Encoding:chunked
Vary:X-UA-Device
Via:1.1 SYDTMG01
X-Cache-Metadata:
X-Robots-Tag:noindex
X-UA-Device:desktop
Here is what I can see in the Network tab of Chrome Dev tools with url which doesnt work:
Request URL:http://ip:port/pgif.jsonp?callback=jQuery1910627754604909569_1386116200762&tags=jquery&tagmode=any&format=json&_=1386116200763
Request Method:GET
Status Code:200 OK
Request Headersview source
Accept:*/*
Accept-Encoding:gzip,deflate,sdch
Accept-Language:en,fr-FR;q=0.8,fr;q=0.6
Connection:keep-alive
Host:ip:port
Referer:http://ip:port/MyApp/index.html
User-Agent:Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.57 Safari/537.36
Query String Parametersview sourceview URL encoded
callback:jQuery1910627754604909569_1386116200762
tags:jquery
tagmode:any
format:json
_:1386116200763
Response Headersview source
Accept-Ranges:bytes
Access-Control-Allow-Origin:*
Content-Length:6616
Content-Type:application/javascript
Date:Thu, 01 Jan 1970 02:02:33 GMT
ETag:"68647623"
Last-Modified:Thu, 01 Jan 1970 01:23:16 GMT
Server:lighttpd/1.4.30
So as you can see, in the last one, I added Access-Control-Allow-Origin:* in the config of my lighttpd webserver, which doesnt improve the situation.
so I dont really understand, I receive an Ok answer from the webserver but my success function is never called.
Here is the JSONP file I'm trying to access on my webserver:
var tumblr_api_read = {"tumblelog":{"title":"puppy gifs"},"posts-start":0,"posts-total":"18"}
So, I didn't managed to make the JSONP work with my web server but I found a different way to solve my problem:
I followed the "CORS from JQuery" from html5rocks.com/en/tutorials/cors
And I'm now able to read my file sitting on my webserver.
It seems like if I want to edit my file, I would need to configure my web server to be able to handle the preflight request. As explained in x3dom.readthedocs.org/en/latest/notes/cors.html