• Resolved Lian

    (@lianthangtial)


    Hi SiteGround,

    I cannot leverage browser caching for web-app-manifest. I get that warning on GTmetrix. I added the following code in my .htaccess file but the warning remains. Please help me out.

    ##My current .htaccess file

    # START PHP VERSION CHANGE forced by SG Optimizer
    AddHandler application/x-httpd-php74 .php .php5 .php4 .php3
    # END PHP VERSION CHANGE

    ## LEVERAGE BROWSER CACHING ##
    <IfModule mod_expires.c>
    ExpiresActive On
    ExpiresByType image/jpg “access 1 year”
    ExpiresByType image/jpeg “access 1 year”
    ExpiresByType image/gif “access 1 year”
    ExpiresByType image/png “access 1 year”
    ExpiresByType text/css “access 1 month”
    ExpiresByType application/pdf “access 1 month”
    ExpiresByType application/x-javascript “access 1 month”
    ExpiresByType application/javascript “access 1 month”
    ExpiresByType application/x-shockwave-flash “access 1 month”
    ExpiresByType application/manifest+json “access plus 1 week”
    ExpiresByType application/x-web-app-manifest+json “access plus 0 seconds”
    ExpiresByType text/cache-manifest “access plus 0 seconds”
    ExpiresByType image/x-icon “access 1 year”
    ExpiresDefault “access 2 days”
    </IfModule>
    ## LEVERAGE BROWSER CACHING ##

    <IfModule mod_deflate.c>
    <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE “application/atom+xml” \
    “application/json” \
    “application/ld+json” \
    “application/manifest+json” \
    “application/x-web-app-manifest+json” \
    “text/cache-manifest” \
    </IfModule>
    </IfModule>

    # BEGIN WordPress
    RewriteEngine On
    RewriteBase /
    RewriteRule ^index\.php$ – [L]
    RewriteCond %{REQUEST_FILENAME} !-f
    RewriteCond %{REQUEST_FILENAME} !-d
    RewriteRule . /index.php [L]
    # END WordPress

    Before the above code, I tried the following code for LBC and Gzip, but my site resulted in “500 – Internal Server Error”.

    # Leverage Browser Caching by SG-Optimizer
    <IfModule mod_expires.c>
    ExpiresActive on
    ExpiresDefault “access plus 6 months”
    # CSS
    ExpiresByType text/css “access plus 1 year”
    # HTML components (HTCs)
    ExpiresByType text/x-component “access plus 2 months”
    # HTML
    ExpiresByType text/html “access plus 6 months”
    # JavaScript
    ExpiresByType application/javascript “access plus 1 year”
    ExpiresByType application/x-javascript “access plus 1 year”
    # Manifest files
    ExpiresByType application/x-web-app-manifest+json “access plus 0 seconds”
    ExpiresByType text/cache-manifest “access plus 0 seconds”
    # Media
    ExpiresByType audio/ogg “access plus 1 year”
    ExpiresByType image/gif “access plus 1 year”
    ExpiresByType image/jpg “access plus 1 year”
    ExpiresByType image/jpeg “access plus 1 year”
    ExpiresByType image/png “access plus 1 year”
    ExpiresByType image/svg “access plus 1 year”
    ExpiresByType image/svg+xml “access plus 1 year”
    ExpiresByType video/mp4 “access plus 1 year”
    ExpiresByType video/ogg “access plus 1 year”
    ExpiresByType video/webm “access plus 1 year”
    ExpiresByType image/x-icon “access plus 1 year”
    ExpiresByType application/pdf “access plus 1 year”
    ExpiresByType application/x-shockwave-flash “access plus 1 year”
    # Web feeds
    ExpiresByType application/atom+xml “access plus 1 hour”
    ExpiresByType application/rss+xml “access plus 1 hour”
    # Web fonts
    ExpiresByType application/font-woff “access plus 1 year”
    ExpiresByType application/font-woff2 “access plus 1 year”
    ExpiresByType application/vnd.ms-fontobject “access plus 1 year”
    ExpiresByType application/x-font-ttf “access plus 1 year”
    ExpiresByType font/opentype “access plus 1 year”
    </IfModule>
    # END LBC
    # GZIP enabled by SG-Optimizer
    <IfModule mod_deflate.c>
    <IfModule mod_filter.c>
    AddOutputFilterByType DEFLATE “application/atom+xml” \
    “application/javascript” \
    “application/json” \
    “application/ld+json” \
    “application/manifest+json” \
    “application/rdf+xml” \
    “application/rss+xml” \
    “application/schema+json” \
    “application/vnd.geo+json” \
    “application/vnd.ms-fontobject” \
    “application/x-font-ttf” \
    “application/x-javascript” \
    “application/x-web-app-manifest+json” \
    “application/xhtml+xml” \
    “application/xml” \
    “font/eot” \
    “font/opentype” \
    “image/bmp” \
    “image/svg+xml” \
    “image/vnd.microsoft.icon” \
    “image/x-icon” \
    “text/cache-manifest” \
    “text/css” \
    “text/html” \
    “text/javascript” \
    “text/plain” \
    “text/vcard” \
    “text/vnd.rim.location.xloc” \
    “text/vtt” \
    “text/x-component” \
    “text/x-cross-domain-policy” \
    “text/xml”
    </IfModule>
    </IfModule>
    # END GZIP

    Thank so much in advance

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

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    The SG Optimizer plugin sets correctly those for both GZIP and LBC:

    LBC:

    # Manifest files
    ExpiresByType application/x-web-app-manifest+json “access plus 0 seconds”
    ExpiresByType text/cache-manifest “access plus 0 seconds”

    and that’s the secrion for GZIP:

    “application/javascript” \
    “application/json” \
    “application/ld+json” \
    “application/manifest+json” \

    Change those but note that we may rewrite such rules set by us on plugin update.

    In addition to that, rewrite rules are recursive which means that rules in the parent folder if such exist will affect your site even if outside the document root. For example, if you have rules like this:

    <IfModule mod_headers.c>
    Header set Cache-Control “no-cache, no-store, must-revalidate”
    Header set Pragma “no-cache”
    Header set Expires 0
    </IfModule>

    They will affect LBC in all sites under that directory. I think it’s worth checking. One more thing – your site goes through CloudFlare, check for such configs on their end too.

    Thread Starter Lian

    (@lianthangtial)

    Hi Hristo, thanks so much the the quick response.

    Could you please provide me full .htaccess file code for SG Optimizer including LBC and Gzip, so I can simply copy/paste to my .htaccess file? I messed up everything, and don’t have the original code added by your awesome plugin anymore.

    Also, under Environment Optimization, it says LBC and Gzip are automatically enabled by default. But, I don’t see such code in my .htaccess file. There is only WordPress default Begin/End WordPress code.

    It’s the same for all of my websites hosted on SiteGround. May be (not sure) I removed them long time ago.

    Is there a way to let the plugin add those code again? I deactivate and activate the plugin a few times but nothing is added to .htaccess file.

    Thank you

    Plugin Author Hristo Pandjarov

    (@hristo-sg)

    SiteGround Representative

    Disable and enable the functionality and the code will be generated anew. You can see your .htaccess file through the File Manager tool or via FTP / SSH. Each piece of code is commented so it’s easy to spot what handles what ??

    Thread Starter Lian

    (@lianthangtial)

    Hi Hristo,

    Thanks for the reply.

    There is NO ‘enable/disable’ option in the plugin screenshot here]. Please help me out. I’m still stuck.

    Thank you

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Cannot LBC for Web App Minifest’ is closed to new replies.