Mobile app version of vmapp.org
Login or Join
Carla537

: How to fix "No Etag header found" error? I tested my website on ready.mobi and it shows MAJOR FAIL All page assets should use appropriate Etag headers to enable client-side

@Carla537

Posted in: #Htaccess #Mobile #Optimization #Seo

I tested my website on ready.mobi and it shows


MAJOR FAIL

All page assets should use appropriate Etag headers to
enable client-side caching and speed up future page loads

No Etag header found.



FixIt page doesn't give me anything helpful - what can I do to solve that problem? .htaccess?

ps. My website runs on some external virtual server with Apache, it's using CodeIgniter PHP framework.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Carla537

2 Comments

Sorted by latest first Latest Oldest Best

 

@Alves908

All page assets should use appropriate Etag headers

My website runs on some external virtual server with Apache


You can't realistically send ETag headers for your page assets (ie. static resources: images, scripts, css) using PHP as it would involve sending all the requests for these, otherwise static, resources through PHP which is only going to make everything a lot slower and processor intensive which is defeating the object of setting ETags in the first place.

Fortunately, Apache has ETag capability for static files built in. It is enabled by default in Apache, but hosts tend to disable this feature. It can be enabled/overridden in .htaccess using the FileETag directive, providing your host has permitted you to do so with the AccessOverride FileInfo directive in the server config.

In .htaccess (or server config):

# Set ETags based on the files i-node, last modified time and file size (default)
FileETag INode MTime Size


Note that if you have load balancing across multiple servers you may want to remove the INode keyword, as this will vary from server to server, so would otherwise result in different ETags being sent when the file has not actually changed.

This should be enough to actually set the ETag header. However, you need to also make sure that you aren't blocking caching by sending a Cache-Control: no-store header (or similar) as the browser then won't send the corresponding If-None-Match header with the ETag value previously sent in the response. Both are required. ETag validation should be used in conjunction with regular browser caching.

Reference: httpd.apache.org/docs/2.4/mod/core.html#fileetag

10% popularity Vote Up Vote Down


 

@Annie201

In PHP, you can use the header function to specify a custom Etag as follows:

$et="11111"; // any custom etag value
header("ETag: "".$et.""",true);


Just make sure when you update the webpage in question that the etag value is updated. If you don't want to do a manual etag update, you can use this code instead:

$et=md5(time()); // 32-bit etag value calculated based on current time in seconds since year 1970.
header("ETag: "".$et.""",true);


Since you're using a framework, look in the PHP source for other header() functions and place any of the above code in with that.

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme