Seems there is a bug in the FileEtag directive. Here is a test to show what i mean.
The test files will be:
PNG Image file :
CSS Stylesheet file :
Now, with an empty .htaccess file the response headers are as follows (take note of the ETag header for each file):
Response:
Response:
Everything looks good.
Results
Etag for test.png :
Etag for test.css :
On my server Etags by default are output in a 3-component display made up of encoded versions of:
Now, let's modify our empty .htaccess file to include these lines only:
Take note of the
Etag for test.png :
Etag for test.css :
So, let's re-run our tests and see what we get.
Response:
Response:
Hmmm..something looks wrong.
Results
Etag for test.png :
Etag for test.css :
Notice how instead of getting just 2 components we are still getting 3 but worse is the 3rd component (the
So it seems this is not a problem caused by me or using things like Wordpress since my htaccess file is bypassing them entirely. It seems LiteSpeed has a bug with ETags if someone attempts to make use of the FileETag directive in their htaccess file. I'd love to be wrong about this but it seems to point to the server software.
Playing further if you modify the
Now, if you modify the FileEtag to include all 3 components ie. FileETag MTime Size INode then the output is correct, and the result is just like the default process of showing all 3 components (as if my htaccess was empty).
The test files will be:
PNG Image file :
test.png
CSS Stylesheet file :
test.css
Now, with an empty .htaccess file the response headers are as follows (take note of the ETag header for each file):
Response:
test.png
Code:
Etag: "64076-59091ddd-a998062746762090"
Accept-Ranges: bytes
Cache-Control: public, max-age=604800
Connection: Keep-Alive
Content-Length: 409718
Content-Type: image/png
Date: Mon, 08 May 2017 16:25:04 GMT
Expires: Mon, 15 May 2017 16:25:04 GMT
Last-Modified: Wed, 03 May 2017 00:01:33 GMT
Server: LiteSpeed
test.css
Code:
Etag: "4b-591098b8-3b36b002c17673a0"
Accept-Ranges: bytes
Cache-Control: public, max-age=604800
Connection: Keep-Alive
Content-Length: 75
Content-Type: text/css
Date: Mon, 08 May 2017 16:19:50 GMT
Expires: Mon, 15 May 2017 16:19:50 GMT
Last-Modified: Mon, 08 May 2017 16:11:36 GMT
Server: LiteSpeed
Results
Etag for test.png :
64076-59091ddd-a998062746762090
Etag for test.css :
4b-591098b8-3b36b002c17673a0
On my server Etags by default are output in a 3-component display made up of encoded versions of:
<File's Size> -<File's Modified Time> -<INode>
in that order.Now, let's modify our empty .htaccess file to include these lines only:
Code:
<FilesMatch "\.(gif|jpg|png|css)$">
FileETag MTime Size
</FilesMatch>
FileETag
directive. This tells the server to modify the ETag output header to use only 2-components instead of all 3. More specifically, it says to output the ETag header to use only the <File's Size> -<File's Modified Time>
, and exclude the <INode>
component. So, if its functioning correctly the output for both should be:Etag for test.png :
64076-59091ddd
Etag for test.css :
4b-591098b8
So, let's re-run our tests and see what we get.
Response:
test.png
Code:
Etag: "64076-59091ddd-0"
Accept-Ranges: bytes
Cache-Control: public, max-age=604800
Connection: Keep-Alive
Content-Length: 409718
Content-Type: image/png
Date: Mon, 08 May 2017 16:12:27 GMT
Expires: Mon, 15 May 2017 16:12:27 GMT
Last-Modified: Wed, 03 May 2017 00:01:33 GMT
Server: LiteSpeed
test.css
Code:
Etag: "4b-591098b8-0"
Accept-Ranges: bytes
Cache-Control: public, max-age=604800
Connection: Keep-Alive
Content-Length: 75
Content-Type: text/css
Date: Mon, 08 May 2017 16:21:11 GMT
Expires: Mon, 15 May 2017 16:21:11 GMT
Last-Modified: Mon, 08 May 2017 16:11:36 GMT
Server: LiteSpeed
Results
Etag for test.png :
64076-59091ddd-0
Etag for test.css :
4b-591098b8-0
Notice how instead of getting just 2 components we are still getting 3 but worse is the 3rd component (the
<INode>
part) is now outputting as "-0 " instead of just being excluded (dropped) entirely.So it seems this is not a problem caused by me or using things like Wordpress since my htaccess file is bypassing them entirely. It seems LiteSpeed has a bug with ETags if someone attempts to make use of the FileETag directive in their htaccess file. I'd love to be wrong about this but it seems to point to the server software.
Playing further if you modify the
FileEtag
directive to say use only 1 component such as MTime only the output will be in the format: "0-<File's Modified Time>-0
"...it now includes two "-0 " parts instead of dropping them, which is even more wrong.Now, if you modify the FileEtag to include all 3 components ie. FileETag MTime Size INode then the output is correct, and the result is just like the default process of showing all 3 components (as if my htaccess was empty).
Last edited by a moderator: