Repository navigation
Document how to serve theme files and catalogue images from a CDN - #83
Conversation
…n the trusted proxies wording
|
Thanks, the page reads well and most of it matches the code. One thing to fix before merge, and two smaller points. The image path is wrong. With TheliaLibrary, which Flexy needs, the LiipImagine resolver writes derivatives under
With Line 140 says protected files are sent |
…ory shops and explain why downloads are private
New page
getting-started/cdn.md(Next and 3.2): how to serve theme files and catalogue images from a CDN.Content
url_sitethenSYMFONY_TRUSTED_HOSTS, and the trusted proxies.ASSETS_CDN_URLthroughframework.assets.base_urls,MEDIA_CDN_URLthrough LiipImagine'sProxyResolver. Both files can be committed and stay inert while the variable is empty. The CORS header is then required.asset-map:compile), the WebP setting that makes every image uncacheable, protected files that must stay out of CDN caching, HTML.curlcommands and what to look at in the browser.The nginx page gets a separate fix: its static files location had no
try_files, so/media/cache/resolve/...never reached PHP and an image derivative not generated yet stayed broken (also in 3.0 and 3.2).How it was checked
On a shop running 3.2 and the core development version, with Flexy and the default back office theme, behind a caching nginx proxy that behaves as a pull CDN. It is not a commercial CDN, and the page says so.
Measured with curl and Chromium in both setups: URLs, cache misses then hits, private HTML and protected files never cached, scripts blocked without the CORS header, no purge after a deploy, a forged
Hostrefused with 400 once trusted hosts are set, console commands failing withUntrusted Host "localhost"whileurl_siteis empty. The nginx fix was checked in a throwaway nginx:/media/cache/resolve/...answered 404 before and reaches PHP after.Known limitation in the back office theme
thelia/backoffice-default-twig-templateloadsbackoffice/app.jsthroughasset(), which followsbase_urls, butbo_importmap()writespublicPathvalues on the shop's domain. WithASSETS_CDN_URLset, the browser requests undigested files on the CDN domain (/assets/frontOffice/flexy/backoffice/bootstrap.js, 404) and the back office loses its scripts. Same code in 1.2.2 and in the development version. The page warns againstASSETS_CDN_URLwith this theme until it is fixed.Published versions
Labelled
released: the nginx fix corrects a configuration already published for 3.0 and 3.2, and the 3.2 copy of the page describes released code (3.2, default-twig 1.2.2). It leaves out the link to the reverse proxy cache guide, a 3.3 feature that only exists in Next.Build:
npm run buildpasses with no broken link.