Reputation: 150
I deployed a WordPress site using high availability WordPress pre-built image on Google Platform.
I enabled the CDN on backend service, but GTmetrix said that CSS and JS are not in CDN.
I'm thinking that I did something wrong host and path rule. Am I right?
If so, could please check the bellow image and give me some advises.
Or you direct me to other solution. Thanks
Upvotes: 1
Views: 754
Reputation: 382
In order to let Google Cloud CDN cache your CSS and JS files,
You'll need to modify the HTTP headers for CSS, JS files served from backend instance like the following:
Cache-control=Public
max-age
ors-maxage
directive, or anExpires
Since Google Cloud CDN does not provide console to configure the cache methods, the only way to do that is to modify the config files of your backend web server settings,
For example, httpd.conf or .htaccess for Apache HTTP Web Server, or nginx.conf for Nginx web server.
Map to your pre-built image, it'll be the Content Serving Nodes of the WordPress High Availability deployment, since only Content Serving Nodes are public-facing.
You can refer to the architecture diagram of WordPress High Availability:
Your host and URL paths are right, that's how WordPress High Availability works.
Only admin related URLs served by Admin Node, other requests will be served by Content Serving Nodes.
I would suggest you do the following:
/var/www/html/.htaccess
file to modify the Cache Headers:# Cache 1 Month for CSS and JS files
<filesMatch ".(css|js)$">
Header set Cache-Control "max-age=2592000, public"
</filesMatch>
Upvotes: 1