I am using WordPress along with Autoptimize and Cloudflare, and using Locally hosted fonts. I can't leverage browser caching on my site.
I tried using Cloudflare Page rules to Leverage 1 year browser caching on all resources.
It worked, and most of my site was getting cached EXCEPT FONTS.
I know fonts are heavy and can have negative impact on performance.
I tried the following code in htaccess file in my server root.
# Fonts
# Add correct content-type for fonts
AddType application/vnd.ms-fontobject .eot
AddType application/x-font-ttf .ttf
AddType application/x-font-opentype .otf
AddType application/x-font-woff .woff
AddType image/svg+xml .svg
<IfModule mod_expires.c>
ExpiresActive on
ExpiresDefault "access plus 2 days"
ExpiresByType application/vnd.ms-fontobject "access plus 1 year"
ExpiresByType application/x-font-ttf "access plus 1 year"
ExpiresByType application/x-font-opentype "access plus 1 year"
ExpiresByType application/x-font-woff "access plus 1 year"
ExpiresByType application/font-woff2 "access plus 1 year"
</IfModule>
# END Expire headers
# BEGIN Cache-Control Headers
<ifModule mod_headers.c>
<filesMatch "\.(ico|jpe?g|png|gif|swf|mp4|mov|css|js|json|woff|woff2)$">
Header add Cache-Control "public"
</filesMatch>
<filesMatch "\.(x?html?|php)$">
Header add Cache-Control "private, must-revalidate"
</filesMatch>
</ifModule>
But it didn't work.
As far as I know the below above code should have done the trick to cache the Fonts and JSON.
Please help me figure out the correct way to implement it.
Warnings about fonts not being cached:
Leverage browser caching of static assets: 91/100 Learn More WARNING - (2.0 days) - https://milyin.com/superpwa-manifest.json
Leverage browser caching of static assets: 91/100 Learn More WARNING - (2.0 days) - https://milyin.com/wp-content/uploads/omgf/neve-google-font-poppins/poppins-normal-700.woff2
WARNING - (2.0 days) - https://milyin.com/wp-content/uploads/omgf/neve-google-font-poppins/poppins-normal-400.woff2
WARNING - (2.0 days) - https://milyin.com/wp-content/uploads/omgf/neve-google-font-poppins/poppins-normal-500.woff2