Cake\Network\Response::etag PHP Method

etag() public method

Second parameter is used to instruct clients that the content has changed, but semantically, it can be used as the same thing. Think for instance of a page with a hit counter, two different page views are equivalent, but they differ by a few bytes. This leaves off to the Client the decision of using or not the cached page. If no parameters are passed, current Etag header is returned.
public etag ( string | null $hash = null, boolean $weak = false ) : string | null
$hash string | null The unique hash that identifies this response
$weak boolean Whether the response is semantically the same as other with the same hash or not
return string | null
    public function etag($hash = null, $weak = false)
    {
        if ($hash !== null) {
            $this->_headers['Etag'] = sprintf('%s"%s"', $weak ? 'W/' : null, $hash);
        }
        if (isset($this->_headers['Etag'])) {
            return $this->_headers['Etag'];
        }
        return null;
    }