Forum Moderators: coopster

Message Too Old, No Replies

do you guys use ETag?

seems not works in some situation

         

Xuefer

4:52 am on May 8, 2003 (gmt 0)

10+ Year Member



in ie
it can't work with Content-Encoding: gzip?

how many of u succeed on it?
if possible, do at least 2 refresh, and paste the request/reponse headers

Xuefer

5:07 am on May 8, 2003 (gmt 0)

10+ Year Member



this is my test;
GET /test/test.php HTTP/1.1
Accept: */*
Accept-Language: xml,zh-cn;q=0.8,en-us;q=0.5,zh;q=0.3
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: www.our-sky.com-
Connection: Keep-Alive
Cookie: a=b

HTTP/1.1 200 OK
Date: Thu, 08 May 2003 03:28:12 GMT
Server: Apache/2.0.45 (Win32) PHP/4.3.0
Accept-Ranges: bytes
X-Powered-By: PHP/4.3.0
Vary: Accept-Language,User-Agent,Accept-Encoding
Expires:
Cache-Control: private, proxy-revalidate
Pragma:
Content-Language: zh-cn
ETag: "ada6b62797550f1f4712a893276bebe2"
Content-Encoding: gzip
Content-Length: 133
MyHeader: D=110158
Content-Type: text/html; charset=gb2312

===================

GET /test/test.php HTTP/1.1
Accept: */*
Accept-Language: xml,zh-cn;q=0.8,en-us;q=0.5,zh;q=0.3
Accept-Encoding: gzip, deflate
If-None-Match: "f3a8488db4bed04e0a9a42b185b6cdf2"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0)
Host: www.our-sky.com-
Connection: Keep-Alive
Cookie: a=b

HTTP/1.1 200 OK
Date: Thu, 08 May 2003 03:31:34 GMT
Server: Apache/2.0.45 (Win32) PHP/4.3.0
Accept-Ranges: bytes
X-Powered-By: PHP/4.3.0
ETag: "f3a8488db4bed04e0a9a42b185b6cdf2"
Content-Length: 3384
MyHeader: D=10014
Content-Type: text/html

=========

the first one, ie did not send back ETag as If-None-Match
but the second one did

i tried to change headers, but get no definite effect

daisho

1:35 am on May 9, 2003 (gmt 0)

10+ Year Member



IE will only send the ETag of If-Modified-Since headers if it has a cached version of the page. If not then it will not send it.

btw I use these headers with GZip just fine.

Xuefer

4:14 am on May 9, 2003 (gmt 0)

10+ Year Member



a simple script:
with gzip and after 2 refresh:
<?php
$c = "abcdefg";
$etag = '"' . md5($c) . '"';
header("ETag: $etag");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
$c = gzencode($c, 3); header("Content-Encoding: gzip");
echo $c;
?>

===========================
GET /test/test.php HTTP/1.1
Accept: */*
Accept-Language: xml,zh-cn;q=0.8,en-us;q=0.5,zh;q=0.3
Accept-Encoding: gzip, deflate
If-Modified-Since: Fri, 09 May 2003 04:14:21 GMT; length=7
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))
Host: www.our-sky.com-
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Fri, 09 May 2003 04:14:22 GMT
Server: Apache/2.0.45 (Win32) PHP/4.3.2-RC2
X-Powered-By: PHP/4.3.2-RC2
ETag: "7ac66c0f148de9519b8bd264312c4d64"
Last-Modified: Fri, 09 May 2003 04:14:22 GMT
Content-Encoding: gzip
Transfer-Encoding: chunked
Content-Type: text/html
===========================

without gzip and after 2 refresh:
<?php
$c = "abcdefg";
$etag = '"' . md5($c) . '"';
header("ETag: $etag");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");
// $c = gzencode($c, 3); header("Content-Encoding: gzip");
echo $c;
?>

===========================
GET /test/test.php HTTP/1.1
Accept: */*
Accept-Language: xml,zh-cn;q=0.8,en-us;q=0.5,zh;q=0.3
Accept-Encoding: gzip, deflate
If-Modified-Since: Fri, 09 May 2003 04:15:11 GMT
If-None-Match: "7ac66c0f148de9519b8bd264312c4d64"
User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))
Host: www.our-sky.com-
Connection: Keep-Alive

HTTP/1.1 200 OK
Date: Fri, 09 May 2003 04:15:13 GMT
Server: Apache/2.0.45 (Win32) PHP/4.3.2-RC2
X-Powered-By: PHP/4.3.2-RC2
ETag: "7ac66c0f148de9519b8bd264312c4d64"
Last-Modified: Fri, 09 May 2003 04:15:13 GMT
Transfer-Encoding: chunked
Content-Type: text/html
===========================

how do u think of this result?

daisho

11:54 am on May 9, 2003 (gmt 0)

10+ Year Member



I don't us the gz function directly. I use output buffering. Try:

<?php
$c = "abcdefg";
$etag = '"' . md5($c) . '"';
header("ETag: $etag");
header("Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT");

ob_start('ob_gzhandler');
echo $c;
?>

Xuefer

3:56 pm on May 9, 2003 (gmt 0)

10+ Year Member



sorry, but failed :(

what version do u testing on?

failed on both
win2k with ie6 (lastest)
win98 with ie5.0
apache2 with php+apache2handler

only Last-Modified is send back as If-Modified-Since

daisho

6:46 pm on May 9, 2003 (gmt 0)

10+ Year Member



I run Apache 1.x w/ php4.3.1 on Linux.

I'm not sure what you mean by:


only Last-Modified is send back as If-Modified-Since

The server sends "Last-Modified" and the client will only send "If-Modified-Since" if it has a cached copy of the page in which it received a "Last-Modified" for.

daisho.

Xuefer

2:05 am on May 10, 2003 (gmt 0)

10+ Year Member



what i meant "send back" is exactly same as what u meant
just a short version of your sentence

i can't find out the problem :(

daisho

2:43 am on May 10, 2003 (gmt 0)

10+ Year Member



The only think out of place that I noticed is that in your first example you have an empty "Expires:" header. Not sure if this effects anything but it's definatly not to RFC.

Xuefer

4:08 am on May 10, 2003 (gmt 0)

10+ Year Member



just cos im not able to delete cookies that session_start() set
so i have to overwrite it using header("Expire: ");
but the other sample don't have that problem

daisho

4:10 am on May 10, 2003 (gmt 0)

10+ Year Member



What verison of PHP are you using?

Xuefer

4:47 am on May 10, 2003 (gmt 0)

10+ Year Member



the request/response headers tell u all infos :)

User-Agent: Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.0; (R1 1.3))
Server: Apache/2.0.45 (Win32) PHP/4.3.0
and
Server: Apache/2.0.45 (Win32) PHP/4.3.2-RC2

daisho

2:23 pm on May 10, 2003 (gmt 0)

10+ Year Member



Oh yea. Just not paying attention sorry. When I have a change I'll check it on my server.

daisho.

Xuefer

3:05 pm on May 10, 2003 (gmt 0)

10+ Year Member



thx
www.blunck.info/iehttpheaders.html
this is a useful tool that i used to view headers
works under win2k/xp current, not for win9x/me

u may use var_dump(getallheaders());

[edited by: jatar_k at 4:43 pm (utc) on May 10, 2003]
[edit reason] delinked [/edit]