I’m trying to set up a subdomain/cdn structure to help to parallelize the loading of page resources. The main domain will be accessed under https://www.example.com
always.
The assets files (js, css, etc) will be in a github repo on https://www.example.com
, but in order to parallelize these assets with other content on this domain, I’d need to utilize a subdomain such as assets.example.com
.
Accessing the assets files would look like this:
https://assets.example.com/js/file.js
https://assets.example.com
isn’t an actual web directory so the files would have to be referenced from the other location. Essentially assets
is an alias, but doesn’t fully redirect.
What I’ve tried already is setting assets.example.com
as a CNAME of domain.com
, but it doesn’t seem to work. My next thought was to create an A record, and use htaccess to disable access to any files other than files in specific directories.
In the end I want to be able to access https://assets.example.com/js/file.js
and have it resolve to https://www.example.com/js/file.js
Will this work & are there better solutions?