如何为在没有域(.com)的localhost / IP地址上运行的应用程序创建CDN

问题描述 投票:0回答:1

为了提高应用程序的性能,我想将静态资产托管在CDN上。但是我们尚未使用nginx创建域。如何仍然使用像这样的CDN-express-simple-cdn链接-

https://www.keycdn.com/support/express-cdn-integration

我需要在我托管应用程序的Angular应用程序的app.js文件中编写此domainName.com,->

// Initialize Express in a variable in app.js
var app = express();

// Define Your CDN base path
var CDN = "https://assets.preisheld.ch";
// Register a local variable in your app which contains the CDN function
app.locals.CDN = function(path, type, classes, alt) {
    if(type == 'js') {
        return "<script src='"+CDN+path+"' type='text/javascript'></script>";
    } else if (type == 'css') {
        return "<link rel='stylesheet' type='text/css' href='"+CDN+path+"'/>";
    } else if (type == 'img') {
        return "<img class='"+classes+"' src='"+CDN+path+"' alt='"+alt+"' />";
    } else {
        return "";
    }
};

在这种情况下如何利用CDN?

为了提高应用程序的性能,我想将静态资产托管在CDN上。但是我们尚未使用nginx创建域。如何仍然使用CDN,例如-express-simple-cdn链接-https:...

express subdomain cdn
1个回答
1
投票

还有一个虚拟的地方,您可以在本地IP地址中打开它的同时免费创建domainName.com地址

© www.soinside.com 2019 - 2024. All rights reserved.