Content delivery

Content Delivery Networks (CDNs) allow you to quickly deliver your site content by caching content appropriately for improved speed and performance. Magnolia PaaS uses Fastly as the default CDN. If you’re using Fastly as your CDN, you’ll be able to see all available tabs in the Cockpit.

For more on cache in general for Magnolia PaaS, see Cache.

If you’re not using Fastly, you can still check out the content available on this page (Cache and Redirects) as well as information on Domains, Certificates, and Ingresses as they’re available to you.

Looking for more?

See the other CDN Cockpit tabs available in the following pages:

Cache

You can add cache rules from your Magnolia PaaS Cockpit. Caching reduces requests to Magnolia which helps reduce heavy processing loads and improves performance.

Expand the image here to see the different parts of adding a rule in the Cockpit and is applicable to both cache types.

Rule anatomy

cache rule anatomy

  1. Add a new rule. Once you click this, a new rule is added to the top of the list.

  2. Naming your rule.

  3. Choosing the cache type which is Never or a duration (in minutes).

  4. Add a voter.

  5. Save changes to your rules. This saves changes to Author.

  6. Publish rules to production. This saves changes to Public.

  7. Move rule up or down. Remember the first to match is accepted.

  8. Delete a rule.

Add Browser cache rule

browserCachePolicy is defined in Magnolia.

Rules

  • The rules apply from top to down.

  • The first rule matching the request defines which Cache-Control header will be applied to the response.

Instructions

To add a Browser cache rule:

  1. Go to your Cockpit.

  2. Go to Content delivery > Cache.

  3. Choose the Browser cache tab.

  4. Click Add a new rule.

    The new rule will appear at the top of the rule list where you can edit it.

    1. Give the rule a Name.

    2. Choose the Type.

      Table 1. options
      Type Description

      Never cache

      You guessed it. It’s never cached.

      Cache for

      Allows you to set the time something is cached for (in minutes).

    3. Choose When it happens using the AND or OR options.

    4. Click the symbol if you want to add any voters.

      1. Choose the condition you want and click Add.

        Each condition comes with a preset set of rules you can choose from.

        For example, URL starts with condition comes with an option of starts with or does not start with whereby you can add a pattern to fulfill that requirement.

    5. When you’re happy with your new rule, don’t forget to save you work by going to the top and clicking Save changes.

    6. To put your rules into production, you’ll also need to Publish your new rule.

Add CDN cache rule

It also helps serve cached content when Magnolia is down or having any issues.

Rules

  • The rules apply from top to down.

  • The first rule matching the request defines which Surrogate-Control header will be applied to the response.

    • The Surrogate-Control header takes precedence over the Cache-Control one.

    • Surrogate-Control headers are removed before a response is sent to an end user.

    • In the absence of the Surrogate-Control header, the CDN uses the Cache-Control header.

Instructions

To add a CDN cache rule:

  1. Go to your Cockpit.

  2. Go to Content delivery > Cache.

  3. Choose the CDN cache tab.

  4. Click Add a new rule.

    The new rule will appear at the top of the rule list where you can edit it.

    1. Give the rule a Name.

    2. Add a directive to the Surrogate Control field.

      What values can be added?
      • max-age: defines how long the response entity can be considered fresh in seconds before it considers the cached entity stale.

      • stale-while-revalidate: defines how long in seconds that the cache can reuse a stale response while it revalidates it to a cache.

      Example: max-age=86400, stale-while-revalidate=60

    3. Choose When it happens using the AND or OR options.

    4. Click the symbol if you want to add any voters.

      1. Choose the condition you want and click Add.

        Each condition comes with a preset set of rules you can choose from.

        For example, URL starts with condition comes with an option of starts with or does not start with whereby you can add a pattern to fulfill that requirement.

    5. When you’re happy with your new rule, don’t forget to save you work by going to the top and clicking Save changes.

    6. To put your rules into production, you’ll also need to Publish your new rule.

Create redirects

You can view redirects that you have created or add them directly yourself from the Cockpit.

Redirects prerequisites

You need to ensure the following prerequisites are met in order to use the redirects feature in Magnolia PaaS.

  • You should have already created a domain.

Good to knows

  • The redirects server is a proxy server.

  • Redirects are evaluated in order of appearance when entered. The first match is accepted.

  • Only 3xx status codes are acceptable. Different codes affect the browser in different ways. For more, see here.

  • Wrong entries in a CSV file won’t cause any issues. They’ll simply be ignored.

  • Some applications (like Microsoft Excel) wrap quotations (") around CSV lines. You need to remove those quotations if importing or adding a redirect in the Cockpit.

  • You can use RE2 syntax.

    RE2 Syntax examples

    Regex example

    https://www.example.com/0-9{2}(bar|baz)` matches https://www.example.com/01bar or `\https://www.example.com/14baz

    Wildcard example

    https://www.example.com/(.*)https://www.example.com/$1.html redirects https://www.example.com/test to https://www.example.com/test.html

Redirects settings

By default, redirects are served from the backend. However, you can configure the settings to suit your needs if you want to use a Frontend redirect. Follow the instructions here to do just that:

  1. In your Cockpit, go to Content delivery > Redirects.

  2. Click the Redirects settings button.

  3. In the dialog, choose the settings that best suit your needs.

    1. Under Redirects server, choose Backend or Frontend .

      If choosing Frontend, you’ll need to pass the port number you want to use, such as 8080.

    2. Under Load balancing, choose Round Robin or Cookie based load balancing.

      If choosing Cookie based, you’ll need to give the cookie a name.

      redirects settings
  4. Don’t forget to save your updates.

Add redirects

  1. Go to Content delivery > Redirects.

  2. Select the desired Cluster from the dropdown list.

  3. Select the desired Environment from the dropdown list.

  4. Add a single redirect or import a redirect CSV file.

    • Add redirect

    • Add redirects (CSV)

    1. Click Add redirect.

    2. In the dialog, fill out the following.

      1. The Source URL. This is the place to redirect from.

      2. The Target URL. This is the place to redirect to.

      3. The Code. This is the http status code passed with the redirect. Only 3xx http codes are acceptable.

      4. Click Add redirect to complete the action.

    add single redirect
    1. Click Add redirects (CSV).

    2. Click Choose File to import a CSV file for redirects.

      format
      Source,Target,Code (1)
      1 Only 3xx http codes are acceptable.
      example
      Source,Target,Code
      https://www.example.com/,https://www.example.be/foo.html,308
    3. Select your file.

    4. Click Add redirects (CSV) to complete the action.

    add multiple redirects via csv

Manage redirects

If necessary, you can also edit or delete a redirect.

  1. Go to Content delivery > Redirects.

  2. Select the desired Cluster from the dropdown list.

  3. Select the desired Environment from the dropdown list.

  4. Select the redirect you want to manage.

    1. Click the and select your desired action.

      • Edit

      • Delete

      If editing a redirect:

      1. Click Edit and in the dialog, edit the field(s) you want to change (Source, Target, Code).

      2. Click Edit to confirm the changes.

      edit redirect

      If deleting a redirect.

      1. Click the Delete button.

      2. Confirm that you want to delete the redirect.

Feedback

PaaS

×

Location

This widget lets you know where you are on the docs site.

You are currently perusing through the Magnolia PaaS docs.

Main doc sections

DX Core Headless PaaS Legacy Cloud Incubator modules