Set expire headers and remove etags - is this configuration correct?

I used wpfc command to create the server for a single Wordpress site.

By default, it has W3 Total Cache installed.

In the other post, DaveNaylor mentioned that W3 Total Cache is used to confgure memcache. And leave other settings off.

I am using gtmetrix to test the wordpress site. Yslow keeps on saying that expire headers are missing, and there are etags issue.

To solve this problem, I enabled “Browser Cache”, and ticked all the boxes, such as “Set Expires Header”, “Set Entity Etag (Etag)”

Then I purged the cache in Wordpress Admin, and then I used these command:to reload the server:

ee stack reload ee clean --all

I went back to the gtmetrix website, Yslow still indicate Expire Header and etag are not set correctly, and marked as F

I googled, some people say that put these into .htaccess file under htdocs directory, so I put these code:

<IfModule mod_expires.c>
    ExpiresActive on
    ExpiresByType text/css "access plus 60 days"
    ExpiresByType text/javascript "access plus 60 days"
    ExpiresByType image/ico "access plus 60 days"
    ExpiresByType image/jpg "access plus 60 days"
    ExpiresByType image/jpeg "access plus 60 days"
    ExpiresByType image/gif "access plus 60 days"
    ExpiresByType image/png "access plus 60 days"
    ExpiresByType text/css "access plus 60 days"
    ExpiresByType text/html "access plus 60 days"
</IfModule>

Header unset ETag
FileETag None

It does not work neither.

Then, I googled, and someone say that you should modify your nginx configuration file. I used Winscp, and located the file under directory: /etc/nginx/sites-enabled

It currently has these code, should I modify these code? Would it break the system?

server {


    server_name 45.63.XXX.XXX   www.45.63.XXX.XXX;


    access_log /var/log/nginx/45.63.xxx.xxx.access.log rt_cache; 
    error_log /var/log/nginx/45.63.xxx.xxx.error.log;


    root /var/www/45.63.xxx.xxx/htdocs;
    
    

    index index.php index.html index.htm;


    include common/wpfc.conf;  
    
    include common/wpcommon.conf;
    include common/locations.conf;
    include /var/www/45.63.xxx.xxx/conf/nginx/*.conf;
}

Can anyone point the correct direction to add expire header and config the etags?

Ps. I am using a brand new server Ubuntu 14.04 (64X), installed easyengine, and single site with this command ee site create 45.63.XXX.XXX --wpfc

If you look carefully at w3tc settings, it writes to nginx.conf in the root of the wp install. So in your case:

/var/www/45.63.xxx.xxx/htdocs/nginx.conf

What you need to do is include that in your vhost file in /etc/nginx/sites-enabled so add a line after include include /var/www/45.63.xxx.xxx/conf/nginx/*.conf; that is

include /var/www/45.63.xxx.xxx/conf/htdocs/nginx.conf;

make sure you test nginx restart first via nginx -t, if you have duplicate directives nginx will not start. If the test works, restart nginx and your w3tc settings will be picked up. We’ve done this for our EE installs because we also use iThemes Security which prefers to use that file as well, although iThemes Security allows you to select a different .conf file – we just kept w3tc and iThemes in the same file since w3tc didn’t allow an override.

Another way would be to symlink or an include to something like w3tc.conf in /var/www/45.63.xxx.xxx/conf/nginx/

Note the rtCamp folks may have a better solution and since w3tc is going away in EasyEngine or being deprecated soon perhaps not relying on w3tc for this may be wise.