Build a serverless URL shortener using AWS services like API Gateway, Lambda, DynamoDB, and DAX for caching to increase response time and efficiency. Implement the infrastructure code using Terraform, and easily manage and modify the components of the application to optimize performance and scalability.