We've been making changes to how we organize and display our docs. Our work isn't done but we'd love your feedback.
Getting started
Basics
Domains & Origins
Performance

Configuration
Basics
Conditions
Dictionaries
Domains & Origins
Request settings
Cache settings
Headers
Responses
Performance
Custom VCL
Image optimization
Video

Security
Access Control Lists
Monitoring and testing
Securing communications
TLS
Web Application Firewall

Integrations
Logging endpoints
Non-Fastly services

Diagnostics
Streaming logs
Debugging techniques
Common errors

Account info
Account management
Billing
User access and control

Reference

    Working with Edge Dictionaries using the web interface

      Last updated March 13, 2019

    Edge Dictionaries allow you to create logic that doesn't need to be attached to a configuration service version. Edge Dictionaries are made up of dictionary containers and dictionary items. You can use dictionary items to create and store key-value pairs. Attaching dictionary containers to a service version allows you to turn frequently repeated statements into single function statements that act as a constant.

    Viewing dictionaries

    Depending on how you created your dictionaries, you can view them either under VCL Snippets or the Data link.

    Viewing dictionaries created by VCL snippets

    To view a dictionary under the VCL Snippets link, follow the steps below:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the VCL Snippets link. The snippet titles associated with the currently selected service version appear.
    5. To view the contents of the dictionary, click the View source button.

    Viewing dictionaries created using the web interface

    To view a dictionary via the web interface, navigate to the dictionary management area of your service:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the Dictionaries link under Data. Existing dictionaries, if any, associated with the currently selected service version appear.

    Creating a dictionary

    You can create a dictionary by either using VCL Snippets or via the web interface.

    Creating a dictionary using VCL Snippets

    To create a dictionary using VCL snippets, follow the steps below:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the VCL snippets link. The VCL Snippets page appears.
    5. Click Create snippet. The Create a VCL snippet page appears.

      an example dictionary container created with VCL snippet

    6. In the Name field, type an appropriate name (e.g., Example Dictionary).
    7. From the Type (placement of the snippet), select init.
    8. In the VCL field, create a table and add key-value pairs. For example, if you want to create a table that redirects a URL to another path:

      1
      2
      3
      4
      
      table redirects {
        "/source1": "/dest1",
        "/source2": "/dest2"
      }
      

      where the table is a set of key-value pairs that you can reference in your code. You can replace the contents of this table with different key-value pairs.

    9. Click Create to create the snippet.

    Creating a dictionary via the web interface

    Creating a dictionary via the web interface requires you to create a dictionary container and then create the items that will exist in it.

    Creating a dictionary container

    Start by creating a dictionary container using the following steps:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the Dictionaries link under Data. The Dictionaries page appears.
    5. Click Create a dictionary. The dictionary container name field appears.
    6. In the Name of dictionary field, type a descriptive name for the dictionary (e.g., Example Dictionary).
    7. Click the Add button. The empty dictionary container you created appears.
    8. Click the Activate button to deploy your configuration changes to the service version you're editing.

    Creating a dictionary item

    Once you've created a dictionary container, add items into it:

    1. Click the Add item link. The dictionary item fields appear.
    2. In the Key field, type the unique identifier for some item of data (e.g., example.com).
    3. In the Value field, type the value associated with the unique identifier (e.g., yes)
    4. Click the Add button. The key-value pair appears in the dictionary container. This addition will become effective immediately.

      an example dictionary container with one dictionary item, as it appears in the Fastly web interface

    Using a dictionary

    Once you've created a dictionary, you can start using it.

    Using a dictionary with VCL Snippets

    To start using your dictionary with VCL Snippets, follow the steps below:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the VCL snippets link. The VCL Snippets page appears.
    5. Click Create snippet. The Create a VCL snippet page appears.

      an example dictionary container with subroutine

    6. In the Name field, type an appropriate name (e.g., URL redirect).
    7. From the Type (placement of the snippet) controls, select within subroutine.
    8. From the Select subroutine menu, select recv (vcl_recv).
    9. In the VCL field, add a condition to use the table you created in Creating a dictionary using VCL Snippets. For example, if you need to rewrite your URL destination, you could use:

      1
      2
      3
      
       if (table.lookup(redirects, req.url)) {
         set req.url = table.lookup(redirects, req.url);
       }
      

      where table.lookup checks the dictionary for the desired contents you want. The first parameter is the table being looked in and the second parameter is the key you're looking for. If the key exactly matches the second parameter, that value is returned. Be aware that regex doesn't work with a dictionary lookup.

    10. Click Create to create the snippet.
    11. Click the Activate button to deploy your configuration changes.

    Using a dictionary via the web interface

    To use a dictionary via the web interface, you’ll need to create and add a header. Follow the steps below:

    1. Log in to the Fastly web interface and click the Configure link.
    2. From the service menu, select the appropriate service.
    3. Click the Configuration button and then select Clone active. The Domains page appears.
    4. Click the Content link. The Content page appears.
    5. Click the Create header button. The Create a header window appears.

      Using a dictionary using web interface

    6. Fill out the Create a header fields as follows:
      • In the Name field, type the name of your header rule (for example, Redirect lookup).
      • From the Type menu, select Request, and from the Action menu, select Set.
      • In the Destination field, type the name of the header affected by the selected action (e.g., url).
      • In the Source field, type where the content for the header comes from (e.g., table.lookup(redirects, req.url)).
      • From the Ignore if set menu, select No
      • Leave the Priority field as is.
    7. Click the Create button to create the header. A new header appears on the Content page.

    Specifying when to use the dictionary

    Once you’ve created a header, you can create a condition to specify when to use the dictionary:

    1. Click the Attach a condition link next to new header you just created. The Add a condition message appears.
    2. Click the Create a new request condition button. The Create a new condition page appears.

      adding condition on a dictionary

    3. In the Type field, select Request.
    4. In the Name field, type a name for your condition (e.g., My dictionary condition)
    5. In the Apply if field, type a condition (e.g., table.lookup(redirects, req.url))
    6. Click the Save and apply to button.
    7. Click the Activate button to deploy your configuration changes.

    Editing a dictionary

    Keeping in mind their limitations, dictionaries can be edited using VCL Snippets or via dictionary containers and the items within them can be edited via the web interface.

    Editing a dictionary using VCL Snippets

    You can edit the dictionary name and the condition that was created using VCL Snippets in any unlocked service version:

    1. Find a dictionary associated with an unlocked version of your service.
    2. Click the pencil icon next to the dictionary.You can now make changes to the name and the condition.
    3. Click the Update button once you’re finished with your changes.
    4. Click the Activate button to activate the version you made the edits in and view the changes in your VCL.

    Editing a dictionary container via the web interface

    You can edit the name of a dictionary container that was created via the web interface in any unlocked service version:

    1. Find a dictionary associated with an unlocked version of your service.
    2. Click the pencil icon next to the dictionary container name.
    3. Change the name, then click the Save button.

    Editing a dictionary item

    You can edit the dictionary items within a container at any time. To edit the key-value pair in a dictionary container that was created via the web interface:

    1. Find any dictionary associated with your service in which the key-value pairs appear. Because dictionary items are versionless, the service version you choose doesn't matter. Choose the one that makes the most sense to you.
    2. Hover your cursor over a dictionary item, then click the pencil icon that appears.
    3. Edit the key or value as necessary.
    4. Click the Save button. The changes you make will be immediately applied to your configuration. If your dictionary container has already been associated with a deployed service version, those changes will happen live.

    Deleting a dictionary

    Keeping in mind their limitations, dictionaries can be deleted using VCL Snippets or dictionary containers and the items within them can be deleted via the web interface.

    Deleting a dictionary using VCL Snippets

    You can delete a dictionary using VCL Snippets by following the steps below:

    1. Find a dictionary associated with an unlocked version of your service.
    2. Click the trash can icon on the top right corner of the snippet
    3. Click the Confirm and delete button.
    4. Click the Activate button to deploy your configuration changes to the service version you're editing.

    Deleting a dictionary container via the web interface

    You can delete a dictionary container that was created via the web interface in any unlocked service version:

    1. Find a dictionary associated with an unlocked version of your service.
    2. Click the trash can icon in the top right corner of the dictionary.
    3. Click the Confirm and delete button.
    4. Click the Activate button to deploy your configuration changes to the service version you're editing.

    Deleting a dictionary entry

    You can delete the dictionary entries within a container at any time. To delete a key-value pair included in a dictionary container that was created via the web interface:

    1. Find any dictionary associated with your service in which the key-value pairs appear. Because dictionary items are versionless, the service version you choose doesn't matter. Choose the one that makes the most sense to you.
    2. Hover your cursor over a dictionary item, then click the trash can icon that appears.
    3. Click the Confirm and delete button.
    Back to Top