How to provide the next page of updated content?

Feel free to edit the title if you know how to better formulate the question. (Marking is also a problem.) In this general form, the problem may be too complex, so let's look at a specific example.

You get on-screen stackoverflow questions by requesting a /questions ?sort=newestpage. The link on the next page leads to /questions?page=2 &sort=newest. I believe that on the server side, the query translates into an SQL query with a LIMIT clause. The problem with this approach is that if a new question was added when the user views the first page, his second page will start with some questions that he has already seen. (If he has 10 questions on the page and 10 new questions are added, hell will receive exactly the same content a second time!)

Is there an elegant way to solve this common problem? I understand that this is not such a big problem, at least not for stackoverflow, but still.

The best idea I have (besides storing request history on each client) is to use a format /questions?answer_id=NNN. The server returns the page starting with the requested response and places the identifier of the first response on the next page in the next link to the page. There must be a way to write SQL for this, right?

How is this usually done? Or is there a better way?

+3
source share
4 answers

. , " " , stackoverflow, . , ( cookie, , , ), - , 2, 3 , 1 2.

- someones. , ...

, .

+1

-, , - , , .

, - "" - , , , , - .

0

, , cookie URL- n n+displaynum .

. , , , . /, , , .

0

, SQL ( MySQL) :

SELECT * 
FROM   entries 
WHERE  entry_id >= @last_viewed_entry_id 
ORDER BY entry_id 
LIMIT 50
0

Source: https://habr.com/ru/post/1696628/


All Articles