Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea of retrieving geolocation data from cookie if present #54

Open
girishkumarkh opened this issue Apr 9, 2021 · 2 comments
Open

Idea of retrieving geolocation data from cookie if present #54

girishkumarkh opened this issue Apr 9, 2021 · 2 comments

Comments

@girishkumarkh
Copy link
Contributor

girishkumarkh commented Apr 9, 2021

@rednaks have you thought about retrieving the geolocation from the cookie so that we don't need to call the API every single request?

Use case: a typical user will visit multiple pages per site and it's very unlikely their geolocation will change on every request. But calling the API on every single request can be changed to only when the cookie doesn't exist.

@rednaks
Copy link
Owner

rednaks commented Apr 9, 2021

Hello @girishkumarkh , thanks for the suggestion.

what do you actually mean by take if from the cookies ?
Your description sounds to me like you want a cache for the geolocation data. I already opened an issue for that you can check #10 but I'm wondering, do you use cache cause still have no idea how to implement something that would be generic for everyone, even those who don't use a django cache ...

~r

@girishkumarkh
Copy link
Contributor Author

yea kinda like cache but mostly not using cookies as data storage

User have to add this in settings:

ENABLE_COOKIE = True (has to be true for cache to work)
CACHE_IN_COKKIE = True

The flow will look this:
START
┣ User makes a request
┣ Check IF the user has geolocation in a cookie and is not older than 15 days
┃ ┗ YES: Use the geolocation from the cookie and no API calls made
┃ ┗ NO: Call the API from one of the backends and create the cookie as per process_response function
END

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants