• Documentation
  • Pricing
© 2026 Serverless, Inc. All rights reserved.

Framework

  • Overview
  • Documentation
  • Plugins360
  • Pricing

Learn

  • Blog
  • GuidesUpdated
  • Examples240
  • Courses

Resources

  • Support
  • Security
  • Trust Center
  • Status

Community

  • Slack
  • GitHub47k
  • Forum
  • Meetups

Company

  • About
  • Careers
  • Contact
  • Partners

Legal

  • Terms of Service
  • Privacy Policy
  • Trademark
  • DMCA
Serverless Framework Logo

Serverless Framework

Intro
SetupUpgrading To V4ConceptsTutorialAWS CredentialsLicense Keys
DeployingPackagingBuildingTestingDev ModeServicesFunctions
OverviewHTTP (API Gateway v2)REST (API Gateway v1)ActiveMQApplication Load BalancerAlexa SkillAlexa Smart HomeCloudWatch EventCloudWatch LogCloudFrontCognito User PoolEventBridge EventIoTIoT Fleet ProvisioningKafkaKinesis & DynamoDBMSKRabbitMQS3ScheduleSNSSQSWebsocket
LayersManaged InstancesWeb Apps (Lambda Web Functions)Sandboxes (Lambda MicroVMs)MCP ServersAlertsVersion PruningDomainsIAM Function PermissionsParameters
OverviewSelf-reference serverless.ymlServerless CoreEnvironment VariablesCLI OptionsExternal YAML/JSON FilesJavascript propertiesGitDoppler
OverviewS3 ObjectsSSM Parameter Store & Secrets ManagerCloudFormation Stack Outputs
OverviewVaultTerraform State Output
ResourcesComposing ServicesDeployment BucketStateAgent SkillsPython support
OverviewRuntimeGatewayMemoryBrowserCode InterpreterDev Mode
API Gateway Proxy
OverviewGeneral ConfigurationAuthenticationAPI KeysData SourcesResolversPipeline FunctionsSubstitutionsCachingDelta SyncCustom DomainWAFCLI Commands
Deploying SAM/CFN TemplatesWorkflow Tips
OverviewCreating PluginsCLI OutputCustom CommandsCustom VariablesExtending the Configuration schemaExtending and overriding configuration
OverviewDashboardAxiom
Overviewagent docsagent inspectagent setupagent skills installagent skills list / readdeploydeploy functiondeploy listdevdiffinfoinvokeinvoke localloginlogin awslogin aws ssologsmetricspackageplugin installplugin uninstallprintprunereconcileremoverollbackrollback functionusage
OverviewConcepts
OverviewMetricsTracesTroubleshoot
OverviewNode.jsPython
OutputsProviders
OverviewBranch DeploymentsPreview DeploymentsCustom ScriptsTestingPrivate PackagesNotificationsMono ReposDeploy in your own CI/CDBest PracticesTroubleshootingFAQ
OverviewSetupToolsAWS Integration
Serverless.yml Reference
Examples and TutorialsConfiguration Validation
  1. Usage
  2. App Sync
  3. Caching

AppSync caching

The appSync.caching block creates an AppSync server-side cache for the API, which returns cached resolver results instead of calling the data source again. Use it for read-heavy fields whose data can be a few seconds or minutes stale. AWS bills the cache instance by the hour while it exists, whether or not requests use it.

This configuration creates a small cache and caches only the resolvers that opt in:

appSync:
  name: blog-api
  caching:
    behavior: PER_RESOLVER_CACHING
    type: SMALL
    ttl: 300
  resolvers:
    Query.getPost:
      kind: UNIT
      dataSource: postsTable
      code: resolvers/getPost.js
      caching:
        ttl: 60
        keys:
          - '$context.arguments.id'

The $context.arguments.id key shares each cached post among all callers, which suits data that every caller may read. For a resolver whose result depends on the caller, such as one that checks ownership, add an identity field such as $context.identity.sub to keys, or omit keys to use AppSync's default keys, which include $context.identity.

Caching keys

KeyTypeDefaultDescription
behaviorFULL_REQUEST_CACHING or PER_RESOLVER_CACHINGRequiredFULL_REQUEST_CACHING caches every resolver in a request, keyed on $context.arguments and $context.identity. PER_RESOLVER_CACHING caches only resolvers that set caching.
typeSMALL, MEDIUM, LARGE, XLARGE, LARGE_2X, LARGE_4X, LARGE_8X or LARGE_12XT2_SMALLThe cache instance type. The default is a legacy instance type that AWS discourages, so set type explicitly. LARGE_8X isn't available in every Region.
ttlinteger, 1–36003600Seconds a cached result is kept, for resolvers that don't set their own ttl.
enabledbooleantrueSet to false to delete the cache while keeping the block.
atRestEncryptionbooleanfalseEncrypts cached data at rest. AWS has deprecated this setting; changing it replaces the cache.
transitEncryptionbooleanfalseEncrypts traffic to the cache. AWS has deprecated this setting; changing it replaces the cache.

Per-resolver TTLs and cache keys are set on each resolver; see Resolver caching.

Flush the AppSync cache

To empty the cache without waiting for entries to expire, run serverless appsync flush-cache in the service directory:

serverless appsync flush-cache --stage dev

Related pages

  • AppSync resolvers
  • AppSync CLI commands
  • AppSync API configuration
Edit this page
Prev SubstitutionsNextDelta Sync

Contents

  • AppSync caching
  • Caching keys
  • Flush the AppSync cache
  • Related pages

Related

GuidesPluginsExamplesSlack CommunitySupport