Integrate CakePHP with Medianova CDN
Learn how to integrate CakePHP with Medianova CDN to deliver static assets such as images, CSS, and JavaScript files faster and improve website performance.
CakePHP is an open-source PHP framework based on the MVC (Model-View-Controller) pattern, similar to Zend, Laravel, and Symfony. This guide explains how to configure Medianova CDN for CakePHP version 2.4 and later, enabling your application to serve static content from the nearest CDN edge node instead of the origin server.
Prerequisites
A configured CDN Resource.
A running CakePHP 2.4+ application
Write access to your
./Config/bootstrap.phpfile
Integration Steps
Define CDN Base URLs
Open the configuration file:
./Config/bootstrap.phpAdd the following variables to define Medianova CDN paths for your assets:
<?php
Configure::write('App.imageBaseUrl', 'https://<CDN_ZONE_URL>/img/');
Configure::write('App.cssBaseUrl', 'https://<CDN_ZONE_URL>/css/');
Configure::write('App.jsBaseUrl', 'https://<CDN_ZONE_URL>/js/');Troubleshooting
Assets still load from the origin server
CDN URLs not defined or configuration not reloaded.
Check the bootstrap.php entries and clear the CakePHP cache.
Assets missing or 404 errors
Incorrect CDN path or directory mismatch.
Verify that your img, css, and js directories match the structure in your CDN Resource.
Mixed content warning (HTTP/HTTPS)
HTTPS not enabled on CDN resource.
Enable Shared SSL or Custom SSL in the Medianova Control Panel before using secure URLs.
Last updated
Was this helpful?