Ravindra BagaleCourses & study guides मराठी Track your progress

Ravi Sir's Cards › AWS

Why 302 and ADD clicks?

What is a VPC: your own private network inside one AWS Region, example ThreeTierVpc 10.0.0.0/16.

Why 302 and ADD clicks? Returning 200 with the URL in JSON forces every client to invent redirect logic. Browsers already follow Location. HTTP 302 Found with a Location header is the classic shortener response. ADD on clicks is an atomic DynamoDB increment under concurrent hits. In Lambda: GetItem by shortCode → UpdateItem ADD clicks :1 → return statusCode 302 and headers Location = longUrl. Two
Why 302 and ADD clicks? · Download PNG
Read card text

What this card says

Why do we need it?

Returning 200 with the URL in JSON forces every client to invent redirect logic. Browsers already follow Location.

What is it?

HTTP 302 Found with a Location header is the classic shortener response. ADD on clicks is an atomic DynamoDB increment under concurrent hits.

How to do it

In Lambda: GetItem by shortCode → UpdateItem ADD clicks :1 → return statusCode 302 and headers Location = longUrl.

statusCode: 302

Example

Two phones open /Ab12XyZ at once; both redirect and clicks becomes 2, not a lost update.

See all AWS revision cards