From 88e1d1022219d1b3d8443972e42d0372f5d44d3c Mon Sep 17 00:00:00 2001 From: Catherine Wang Date: Wed, 25 Oct 2023 11:20:21 -0700 Subject: [PATCH] adding info to the cache branch --- README.md | 7 +++++++ infra/resources.bicep | 12 ------------ 2 files changed, 7 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 7f327836..99e3eb24 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,13 @@ This is a Python web app using the Django framework and the Azure Database for PostgreSQL relational database service. The Django app is hosted in a fully managed Azure App Service. This app is designed to be be run locally and then deployed to Azure. You can either deploy this project by following the tutorial [*Deploy a Python (Django or Flask) web app with PostgreSQL in Azure*](https://docs.microsoft.com/azure/app-service/tutorial-python-postgresql-app) or by using the [Azure Developer CLI (azd)](https://learn.microsoft.com/azure/developer/azure-developer-cli/overview) according to the instructions below. +## The Cache branch +The Cache branch in the repository contains sample code to save web response out and user session data in a Redis Cache. For web response caching, if a user clicks into the detailed view of a resturant, the details page will be cached for 60 seconds. This increases the application performance by saving server resource and reducing dependency calls into the PostgreSQL. For user session data such as last viewed restaurant, saving in Redis Cache improves consistency and resiliency comparing with in-memory. +Files changed in the Cache branch: +* ./azureproject/production.py and settings.py - added cache and session middlewares +* ./restaurant_review/views.py - added @cache_page tag and session data "lastViewedRestaurant" +* ./restaurant_review/templates/restaurant_review/index.html - added display for 'LastViewedRestaurant' + ## Requirements The [requirements.txt](./requirements.txt) has the following packages: diff --git a/infra/resources.bicep b/infra/resources.bicep index 0c8e19f3..ad24d717 100644 --- a/infra/resources.bicep +++ b/infra/resources.bicep @@ -321,20 +321,8 @@ resource redisCache 'Microsoft.Cache/redis@2023-04-01' = { enableNonSslPort:false redisVersion:'6' publicNetworkAccess:'Disabled' - //subnetId:virtualNetwork::cacheSubnet.id //commented out b/c vnet injection only works for premium skus } - // resource redisCacheNetwork 'privateEndpointConnections' = { - // name: '${cacheServerName}-privateEndpointConnection' - // properties:{ - // privateLinkServiceConnectionState: { - // actionsRequired: 'Change on the service provider will require updates on the consumer. see https://learn.microsoft.com/en-us/azure/templates/microsoft.cache/redis/privateendpointconnections?pivots=deployment-language-bicep#privatelinkserviceconnectionstate' - // description: 'the private link service connection state for setting up private link' - // status: 'Approved' - // } - // privateEndpoint: cachePrivateEndpoint - // } - // } }