N
N
N2020-10-12 18:53:16
API
N, 2020-10-12 18:53:16

How to disable caching of data received via API?

Given:
Some API (to be developed) counting the number of requests for some methods of this API...

Conditions:
Do not allow caching responses for each method (or some).

More:

Let's imagine the following structure:
- Authors of books;
- Their books;
- Stories (fairy tales) in these books.


In the most banal case, the API would look, for example, like this:

- Method for obtaining authors:
/getAuthors
Result:
id: 1
name: Vasya Pupkin
id: 2
name: Ignat the Great
...


Method for obtaining books by author:
/getBooks/{author_id}
Result:
id: 1
name: Fishing
id: 2
name: Space
...


Method for obtaining stories (fairy tales) from the book:
/getStories/{book_id}
Result:
id: 1
name: How to catch a shark
id: 2
name: How to fly to Mars
...


Let's return to the condition of the problem:
It is necessary to count the number of requests for each method (there are no problems here) and do not give the opportunity to cache the response, for example, the "get books by author" method, so that in the future it would not be possible, once you save the authors' IDs, to directly access this method, bypassing the "get authors" method ...

There are thoughts to replace the ID 'shniks with some kind of "salt/hash", etc...
But I would like to hear your thoughts... because the picture doesn't add up to the end, and I don't want to use crutches :)

I don’t need the code itself and how to do it ... just a train of thought and logic is needed to solve such a problem ...

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry, 2020-10-12
@Fernus

Make authors' IDs in the form of short tokens with the ability to decrypt, and bind them to the user working with the API, as well as the validity period - an hour. Then other users will also not be able to request on someone else's behalf.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question