0
votes

I created a Logic App HTTP GET request that retrieve data from a weather API.

What I would like to achieve is to reduce the calls to the weather API using a cached result only for identical requests.

Example: in my company there are 300 devices that are calling the Logic Apps endpoint with the same latitude and longitude in the query. At this point, I'm assuming, that for every call the Logic App makes a call at the weather API. Instead I'd like that it calls the weather API just the first time and then, for all the identical calls, it returns the cached result.

I'm afraid that, if I use cache-control settings in the header of the request, the Logic App would return the same cached result also if the query is different (for example a different location).

Thanks.

1
are you trying to avoid the devices to call the logic app ??? there is no server side caching I am afraid using logic app - Thomas
@Thomas: no, I'm trying to avoid that the Logic App calls the external API with the same request over and over. But you second statement, I think, is what I wanted to know: Logic App doesn't have server side cache. Thank you - Ale
FYI: To solve my issue I moved from Logic Apps to API Management Service. The latter provide server side caching. - Ale
Just check if the pricing work for you, API management is an expensive service - Thomas

1 Answers

1
votes

As @Thomas said in the comments above, API Management Service is expensive than other services of App Services, like Logic Apps.

However, per my experience, I think you can pay less to implement a cache logic using a few code. For example, it's available and cheap to use Azure Table Storage to store these cache weather data. And you can fetch them via the table partition key & row key as the query parameters of datetime, latitude and longitude from Azure Table.

Here is a simple pseudocode for cache logic.

string partitionKey = "<datetime>"
string rowKey = "<latitude>-<longitude>"
data = fetchWeatherDataFromTable(partitionKey, rowKey)
if data == null {
    data = getWeatherDataFromRemoteAPI()
    storeWeatherDataIntoTable(partitionKey, rowKey, data)
}
return data

Also, you can use other storages like Azure SQL Database or Redis instead of Azure Table Storage. It's up to you.

Hope it helps.