开发者

How to call CSS and JS from a sub-domain - to make loading faster in Magento

When calling css and js files from a sub-domain, what would be the 开发者_开发问答correct way to do this in Magento?


First, make sure the sub-domain resolves to the same folder as the rest of Magento. So a file, "http://www.example.com/file" will appear exactly the same as "http://static.example.com/file".

Then, in Magento's admin, go to System > Configuration > Web > Unsecure and change {{unsecure_base_url}} to your new sub domain (eg. "http://static.example.com/") for the Skin, Media and JavaScript options. Repeat for the "Secure" section too.

Edit:
I just remembered that for secure sub-domains you either need a wildcard certificate or an additional certificate for the sub-domain installed. It might be simpler to skip the "Secure" section because of this, most pages will not be served as secure so the inconvenience is minimal.

Also I've had problems with the image upload for products when using sub-domains, you can get around this with No Flash Uploader.


Just to add to that, it's recommended to set up static files on a different server running Nginx (or other optimized server, not Apache). If you are using separate servers you should share image folder via NFS (export on static files server, mount on all web nodes) so image upload works correctly.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜