About Edge Dictionaries

      Last updated January 18, 2019

    Fastly offers updatable, global, Edge Dictionaries that allow you to store data as key-value pairs and turn frequently repeated statements like this:

    1
    2
    3
    4
    5
    
    if (something == "value1") {
      set other = "result1";
    } else if (something == "value2") {
      set other = "result2";
    }
    

    into a single function that acts as constant, like this:

    1
    2
    3
    4
    5
    
    table <ID> {
      "KEY_STRING": "VALUE_STRING",
      "KEY_STRING2": "VALUE_STRING2",
      ...
    }
    

    for use with a service.

    When Edge Dictionaries might be useful

    How dictionaries work

    Edge Dictionaries are made up of dictionary containers and the dictionary items within them. Once you attach a dictionary container to a version of your service and that service is activated, the data in it becomes "versionless." This means you can add to and update the data an Edge Dictionary contains at any time after it is created, without ever incrementing a service's version.

    For example, say you have a referer block list that changes frequently and you want to associate it with a service. Any time that service's configuration changes, especially if the configuration rolls back to a previous version, you would want the block-listed referer domains to continue to remain with the service configuration instead of being removed. Edge Dictionaries would help you do this.

    How to create and use dictionaries

    To create an Edge Dictionary and use it within your service, start by creating an empty dictionary container and then add its entries in a working version of a service that's unlocked and not yet activated. You can create dictionaries:

    Limitations and considerations

    When creating Edge Dictionaries, keep the following things in mind:

    When making changes to Edge Dictionaries, keep the following things in mind:

    Back to Top