


Research on CDN solutions for Magento resource issues, magento resource cdn solutions
Through understanding of Magento, I found that Magento’s resource files are mainly distributed in three folders: media, js, and skin. , the media folder mainly includes the system’s built-in editor WYSIWYG Editor, all the resources involved in the editor (Static Blocks, Pages, Product Intro, Product Images) and the media resources independently generated by Magento (including the media resources that we allow users to upload files folder); the skin folder is mainly the styles, pictures, and js resources provided by the template (generally, when we re-modify the template, we will change the resources in this folder); the js folder includes Magento official prototype, varien, scriptaculous, mage and other js libraries and ancillary resources (generally we will not touch this folder). All these three folders contain static resources (pictures, js, css, fonts, documents, etc.), which means we can CDN File
By observing the Magento source code, the website’s public method getBaseUrl AT app/core/Mage/Core/Model/Store.php
<span>public</span> <span>function</span> getBaseUrl(<span>$type</span> = self::URL_TYPE_LINK, <span>$secure</span> = <span>null</span><span>) { </span><span>$cacheKey</span> = <span>$type</span> . '/' . (<span>is_null</span>(<span>$secure</span>) ? 'null' : (<span>$secure</span> ? 'true' : 'false'<span>)); </span><span>if</span> (!<span>isset</span>(<span>$this</span>->_baseUrlCache[<span>$cacheKey</span><span>])) { </span><span>switch</span> (<span>$type</span><span>) { </span><span>case</span> self::URL_TYPE_WEB: <span>$secure</span> = <span>is_null</span>(<span>$secure</span>) ? <span>$this</span>->isCurrentlySecure() : (bool)<span>$secure</span><span>; </span><span>$url</span> = <span>$this</span>->getConfig('web/' . (<span>$secure</span> ? 'secure' : 'unsecure') . '/base_url'<span>); </span><span>break</span><span>; </span><span>case</span> self::URL_TYPE_LINK: <span>$secure</span> = (bool) <span>$secure</span><span>; </span><span>$url</span> = <span>$this</span>->getConfig('web/' . (<span>$secure</span> ? 'secure' : 'unsecure') . '/base_link_url'<span>); </span><span>$url</span> = <span>$this</span>->_updatePathUseRewrites(<span>$url</span><span>); </span><span>$url</span> = <span>$this</span>->_updatePathUseStoreView(<span>$url</span><span>); </span><span>break</span><span>; </span><span>case</span> self::URL_TYPE_DIRECT_LINK: <span>$secure</span> = (bool) <span>$secure</span><span>; </span><span>$url</span> = <span>$this</span>->getConfig('web/' . (<span>$secure</span> ? 'secure' : 'unsecure') . '/base_link_url'<span>); </span><span>$url</span> = <span>$this</span>->_updatePathUseRewrites(<span>$url</span><span>); </span><span>break</span><span>; </span><span>case</span> self::URL_TYPE_SKIN: <span>case</span> self::URL_TYPE_JS: <span>$secure</span> = <span>is_null</span>(<span>$secure</span>) ? <span>$this</span>->isCurrentlySecure() : (bool) <span>$secure</span><span>; </span><span>$url</span> = <span>$this</span>->getConfig('web/' . (<span>$secure</span> ? 'secure' : 'unsecure') . '/base_' . <span>$type</span> . '_url'<span>); </span><span>break</span><span>; </span><span>case</span> self::URL_TYPE_MEDIA: <span>$url</span> = <span>$this</span>->_updateMediaPathUseRewrites(<span>$secure</span><span>); </span><span>break</span><span>; </span><span>default</span>: <span>throw</span> Mage::<span>exception</span>('Mage_Core', Mage::helper('core')->__('Invalid base url type'<span>)); } </span><span>if</span> (<span>false</span> !== <span>strpos</span>(<span>$url</span>, '{{base_url}}'<span>)) { </span><span>$baseUrl</span> = Mage::getConfig()->substDistroServerVars('{{base_url}}'<span>); </span><span>$url</span> = <span>str_replace</span>('{{base_url}}', <span>$baseUrl</span>, <span>$url</span><span>); } </span><span>$this</span>->_baseUrlCache[<span>$cacheKey</span>] = <span>rtrim</span>(<span>$url</span>, '/') . '/'<span>; } </span><span>return</span> <span>$this</span>->_baseUrlCache[<span>$cacheKey</span><span>]; }</span>
The method of obtaining URL_TYPE_MEDIA is more complicated. Let’s also take a look at what is written
<span>protected</span> <span>function</span> _updateMediaPathUseRewrites(<span>$secure</span> = <span>null</span>, <span>$type</span> = self::<span>URL_TYPE_MEDIA) { </span><span>$secure</span> = <span>is_null</span>(<span>$secure</span>) ? <span>$this</span>->isCurrentlySecure() : (bool) <span>$secure</span><span>; </span><span>$secureStringFlag</span> = <span>$secure</span> ? 'secure' : 'unsecure'<span>; </span><span>$url</span> = <span>$this</span>->getConfig('web/' . <span>$secureStringFlag</span> . '/base_' . <span>$type</span> . '_url'<span>); </span><span>if</span> (!<span>$this</span>->getConfig(self::<span>XML_PATH_USE_REWRITES) </span>&& Mage::helper('core/file_storage_database')-><span>checkDbUsage() ) { </span><span>$urlStart</span> = <span>$this</span>->getConfig('web/' . <span>$secureStringFlag</span> . '/base_url'<span>); </span><span>$url</span> = <span>str_replace</span>(<span>$urlStart</span>, <span>$urlStart</span> . self::MEDIA_REWRITE_SCRIPT, <span>$url</span><span>); } </span><span>return</span> <span>$url</span><span>; }</span>
We can find that all $type types will always be obtained from getConfig(string configPath), and the obtained saved database can be configured and modified in the background configuration -> general Web -> Unsecure & Secure.
Assume that the entire Magento site is used as a CDN source server, and then the values of BASE_MEDIA_URL, BASE_SKIN_URL, and BASE_JS_URL are changed to CDN addresses. Does this mean that the Magento resources are CDN processed? So I first changed the local machine Install Magento for testing (as the saying goes, practice is the only way to test truth). Since CDN requires domain name resolution, we will ignore it for the time being and will not engage in CDN. However, we can use redirection to a new domain name to represent this CDN. For example, add two domain names to hosts for testing
<span>127.0</span>.<span>0.1</span><span> magento.yourdomain.com </span><span>127.0</span>.<span>0.1</span> mage-cdn.yourdomain.com
Copy the original magento.yourdomain.com configuration in Nginx and delete the PHP parsing section to ensure safety. By the way, add as many resource types as possible to the resources (you can add more later if not enough)
Restart nginx, then log in to the Magento backend and change the original {{base_unsecure_url}} in BASE_MEDIA_URL, BASE_SKIN_URL, and BASE_JS_URL to http://mage-cdn.yourdomain.com/ and {{base_secure_url}} to https: //mage-cdn.yourdomain.com/ Then save the settings and refresh the Magento cache. OK. You're done.
Open http://magento.yourdomain.com/ and try it. Suppose you use another template and add a lot of fonts to it. You may see an error message about cross-domain access:
Font from origin <span>'</span><span>https://mage-cdn.yourdomain.com</span><span>'</span> has been blocked from loading by Cross-Origin Resource Sharing policy: No <span>'</span><span>Access-Control-Allow-Origin</span><span>'</span> header is present on the requested resource. Origin <span>'</span><span>https://magento.yourdomain.com</span><span>'</span> is therefore <span>not</span> allowed access.
He told you that the magento site wants to access some resources of mage-cdn, but since there is no Access-Control-Allow-Origin header, we add add_header Access-Control when configuring the resource files in the mage-cdn site in nginx. -Allow-Origin https://magento.yourdomain.com. Why not use *? If you generously want other websites to be able to access your resources across domains, then you can use *. I recommend using binding there. Where, hehe
Then we open the Magento site, conduct various tests, register, log in, place an order, upload and edit various things in the background. OK, this time we are really done.
The next step is to deploy the CDN. Log in to the CDN service provider and directly set the source site to your magento.yourdomain.com. Generally, CDNs provide CNAME services, so you can generously parse a cdn.yourdomain.com CNAME to provide CDN services. The address abcd.xxxx.com provided to you by the provider. Generally, CDN service providers also provide the addition of headers. You can add the required headers for this CDN, which is the cross-domain request we need. Then configure Magento and then blablabla. Finally, you find a way to let the CDN service provider use your crt certificate. OK It’s done now

最常称为VSCode的VisualStudioCode是开发人员用于编码的工具之一。Intellisense是VSCode中包含的一项功能,可让编码人员的生活变得轻松。它提供了编写代码的建议或工具提示。这是开发人员更喜欢的一种扩展。当IntelliSense不起作用时,习惯了它的人会发现很难编码。你是其中之一吗?如果是这样,请通过本文找到不同的解决方案来解决IntelliSense在VS代码中不起作用的问题。Intellisense如下所示。它在您编码时提供建议。首先检

解决C++代码中出现的“error:redefinitionofclass'ClassName'”问题在C++编程中,我们经常会遇到各种各样的编译错误。其中一个常见的错误是“error:redefinitionofclass'ClassName'”(类‘ClassName’的重定义错误)。这个错误通常出现在同一个类被定义了多次的情况下。本文将

115网盘里会有很多的资源,那么该怎么找资源呢?用户们可以在软件里搜索需要的资源,然后进入下载界面,然后选择存至网盘就可以了。这篇115网盘找资源方法介绍就能够告诉大家具体的内容,下面就是详细的介绍,赶紧来看看吧。115网盘怎么找资源答:在软件里搜索内容,然后点击存至网盘。具体介绍:1、首先在app里输入想要的资源。2、之后点击出现的关键词链接。3、接着进入下载界面。4、点击里面的存至网盘就可以了。

资源管理器.exe在Windows11的安全模式下崩溃?不会了。Microsoft刚刚发布了开发频道的新补丁,虽然此版本没有新功能,但许多修复和改进都进入了Windows预览体验计划,包括资源管理器.exe在安全模式下崩溃的烦人错误。好吧,你现在可以告别它了,至少在Windows预览体验计划中是这样。但与所有这些更新一样,它们也将进入实时Windows服务器。修复了导致资源管理器.exe无法在安全模式下工作的问题。但是,文件资源管理器还进行了其他一些修复,因此Microsoft热衷于使其正常工作

解决PHP报错:继承父类时遇到的问题在PHP中,继承是一种重要的面向对象编程的特性。通过继承,我们能够重用已有的代码,并且能够在不修改原有代码的情况下,对其进行扩展和改进。尽管继承在开发中应用广泛,但有时候在继承父类时可能会遇到一些报错问题,本文将围绕解决继承父类时遇到的常见问题进行讨论,并提供相应的代码示例。问题一:未找到父类在继承父类的过程中,如果系统无

韩小圈是能够观看很多韩剧的软件,那么为什么突然没有资源呢?这个软件可能是因为网络问题,版本问题,或者是版权问题才没有资源。这篇韩小圈突然没有资源原因介绍就能够告诉大家具体的内容,下面就是详细的介绍,赶紧来看看吧。韩小圈为什么突然没有资源了答:由于网络问题,版本问题,版权问题导致具体介绍:1、网络问题解决方法:可以选择不同的网络,然后重新登录软件试试。2、版本问题解决方法:用户们可以从官网上下载这个软件的最新版本。3、版权问题解决方法:有的韩剧是因为版权问题下架,可以选择别的韩剧观看。

win10浏览器自动关闭是怎么回事?我们在使用电脑的时候经常会去用到各种浏览器,而最近有不少用户在Win10电脑中使用浏览器的时候经常会出现自动关闭的情况,那么我们要是遇到这种问题应该怎么解决呢?很多小伙伴不知道怎么详细操作,小编下面整理了Win10系统浏览器自动关闭的解决教程,如果你感兴趣的话,跟着小编一起往下看看吧! Win10系统浏览器自动关闭的解决教程 1、针对浏览器崩溃的问题,可以借助电脑管家所提供的电脑诊所工具进行修复操作。只需要在其中搜索IE浏览器崩溃并点击如图所示立即修复

Steam是十分受欢迎的一个平台游戏,拥有众多优质游戏,可是有些win10用户体现自己下载不了steam,这是怎么回事呢?极有可能是用户的ipv4服务器地址没有设置好。要想解决这个问题的话,你可以试着在兼容模式下安装Steam,随后手动修改一下DNS服务器,将其改成114.114.114.114,以后应当就能下载了。win10下载不了steam怎么办:WIn10下能够试着兼容模式下安装,更新后必须关掉兼容模式,不然网页将无法加载。点击程序安装的属性,以兼容模式运作运行这个程序。重启以增加内存,电


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version
Small size, syntax highlighting, does not support code prompt function

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor
