• Resolved jrothra

    (@jrothra)


    I’m using the free version of WP-O on my site, yet when I run a speed test on GTMetrix, it gives me a 0 Fail for not leveraging browser caching.

    I read on another thread that it may mean that WordPress can’t write to the .htaccess file, yet the Yoast plugin writes to it just fine.

    How do I resolve this?

    • This topic was modified 4 years, 6 months ago by jrothra. Reason: Add link

    The page I need help with: [log in to see the link]

Viewing 8 replies - 1 through 8 (of 8 total)
  • Hi there,

    When you go to WP-Optimize > Cache > Static file headers, what is there?
    This is where WP-Optimize enables you to turn on browser caching, when the server runs on Apache.

    Though looking at your site, it seems to be running on Nginx.

    Unfortunately, Nginx does not offer a solution like Apache’s .htaccess. Which means that browser caching has to be configured on the server.

    If the relevant setting in WP-Optimize doesn’t allow you to enable browser caching, I’d encourage you to check with your hosting.

    Marc.

    Thread Starter jrothra

    (@jrothra)

    When you go to WP-Optimize > Cache > Static file headers, what is there?

    This is what I see: screen shot

    Though looking at your site, it seems to be running on Nginx.

    I have no idea what that is or if my site uses it. I do have an .htaccess file on the server, which does use Apache.

    Thread Starter jrothra

    (@jrothra)

    When I look at the cPanel, there is an option for Apache, so I’m sure the server uses Apache, not Nginx. I have, however, asked the host via a ticket.

    Here’s a screen shot of the Apache handlers section which seems to indicate that it is an Apache server.

    • This reply was modified 4 years, 6 months ago by jrothra.

    Okay, then maybe a “reverse proxy” is used (which means that both Nginx and Apache are used together), because the headers on your site indicate Nginx.

    screenshot

    In that case, and if your hosting doesn’t have more info, you might have to manually edit the .htaccess.

    Here’s the section that WP-Optimize would add:

    # BEGIN WP-Optimize Browser Cache
    <IfModule mod_expires.c>
    	ExpiresActive On
    	ExpiresByType text/css "access 1 month"
    	ExpiresByType text/html "access 1 month"
    	ExpiresByType image/gif "access 1 month"
    	ExpiresByType image/png "access 1 month"
    	ExpiresByType image/jpg "access 1 month"
    	ExpiresByType image/jpeg "access 1 month"
    	ExpiresByType image/webp "access 1 month"
    	ExpiresByType image/x-icon "access 1 month"
    	ExpiresByType application/pdf "access 1 month"
    	ExpiresByType application/javascript "access 1 month"
    	ExpiresByType text/x-javascript "access 1 month"
    	ExpiresByType application/x-shockwave-flash "access 1 month"
    	ExpiresDefault "access 1 month"
    </IfModule>
    
    <IfModule mod_headers.c>
    	<filesMatch "\.(ico|jpe?g|png|gif|webp|swf)$">
    		Header set Cache-Control "public"
    	</filesMatch>
    	<filesMatch "\.(css)$">
    		Header set Cache-Control "public"
    	</filesMatch>
    	<filesMatch "\.(js)$">
    		Header set Cache-Control "private"
    	</filesMatch>
    	<filesMatch "\.(x?html?|php)$">
    		Header set Cache-Control "private, must-revalidate"
    	</filesMatch>
    </IfModule>
    
    #Disable ETag
    FileETag None
    # END WP-Optimize Browser Cache

    So you can manually add this in your .htaccess.

    Thread Starter jrothra

    (@jrothra)

    Hmm… odd, but probably only to me since this is a bit above my head right now.

    I added the info to .htaccess (which I accessed via Yoast > Tools).

    Thread Starter jrothra

    (@jrothra)

    After adding that code to the .htaccess file, I re-ran speed tests. Both Pingdom and GTMetrics/YSlow continue to say I need to “add expires headers.” I thought that this code was doing that.

    Your screenshots aren’t public, so I ran a test on gtmetrix.

    I get B, and F on Yslow.
    Though looking at the assets listed, they’re all external URLs. This means that the settings on your website do work (otherwise you would find your own website’s assets).

    Those resources (and their browser caching settings) are out of your control, as they’re served by third party websites.

    screenshot

    So unfortunately, there isn’t much you can do about that.

    Marc.

    Thread Starter jrothra

    (@jrothra)

    I talked to the web hosting company and they said that the plugin should have been able to write to the .htaccess file, and that it’s odd that it didn’t.

    My thoughts: since I manually added the info, that works, too.

Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘Static File Cache Enabled yet GTMetrix Says “Leverage Browser Caching”’ is closed to new replies.