How are ETag generated by default?

Discussion in 'General' started by romfladef, Mar 16, 2012.

  1. romfladef

    romfladef New Member

    Sorry, the browser's session had expired while I was writing this.

    Hi all, I'm new to the forum: I know that LiteSpeed doesn't handle the FileETag option in .htaccess, but my question is a little different! ;)

    I noticed that the server produce ETag like:


    How are those generated by default? Thank you! ;)
  2. webizen

    webizen Well-Known Member

    Here is a general answer:

    Common methods of ETag generation include using a collision-resistant hash function of the resource's content, a hash of the last modification timestamp, or even just a revision number.


    ETag '-0' is set when "No I-Node in ETag" is set to Yes.
    Last edited: Mar 16, 2012
  3. romfladef

    romfladef New Member

    Usually, ETag are provided by Apache with: INode MTime Size, with CRC32 as cryptographic algorithm... but I noticed that LiteSpeed has another way to generate them (apart from the INode removal by the control panel I can't access in my hosting). I wasn't able to decipher it. I mean, -0 seems to be an incremental number, while I can't understand what the first and the second field represent. There are several chipers to encode ETag, from MD5 to CRC32. I'd like to use the same default algorithm to generate ETag via PHP for dynamic contents, because I can't modify them via FileETag on .htaccess that's unsupported by LiteSpeed for image, etc.! I tried looking at the web servers' sources, but it didn't help! ;)
  4. webizen

    webizen Well-Known Member

    it is unnecessary to use the same algorithm for dynamic contents as LSWS does not honor that anyway.
  5. JohnDavidson

    JohnDavidson New Member

    Hi, I know this is an old thread but i found it when searching for an issue i'm having with ETags that i'm hoping someone can please help me with?
    I have used FileETag MTime Size in my htaccess to configure ETags for use with a cdn. This produces ETags with the following format 0-6106-4f5f3bc1 with the 0 at the front.
    Based on what webizen said "ETag '-0' is set when "No I-Node in ETag" is set to Yes." my htaccess code appears to be correctly configuring my ETags.
    The trouble is, gtmetrix tells me my ETags are misconfigured, and when using chrome developer tools, when i view a page again my static resources with ETags return a 200 response rather than a 304 response.
    I am using the litespeed wordpress plugin also, and this does return a 304 response on repeated view for the main html document. But for some reason i can't seem to get static resources to return a 304 response.
    FileETag MTime Size worked before when i was on an apache server, but after changing to litespeed it doesn't. I don't have access to httpd.conf unfortunately, otherwise i would have tried adding it there.
    Does anyone have any ideas on what's going on with my ETags?
  6. JohnDavidson

    JohnDavidson New Member

    Just spoken to my host about this and they said they are using litespeed server. I found this page which has identified the problem:
    The question now is how can my host modify the Etag settings to not include the inode component as they say there isn't any settings for this?

    EDIT: Found this post which seems like there's a bug which has caused this confusion with gtmetrix
    Last edited: Aug 19, 2017

Share This Page