Email or username:

Password:

Forgot your password?
Francisco Tolmasky

Almost all blogs put “next page” URLs at /2, /3, … /n. These are *bad URLs*, since they’re constantly changing. Instead, do the following: choose how many posts you want per page (p), as usual. But make an exception for the main page, which waits to hit 2*p posts before dumping p posts to the next page all at once. Now your “next pages” won’t change, so they can have persistent URLs! So, number your URLs in *decreasing* order: /n, /n-1, … /1. As a bonus, “/1” conveniently has your first posts!

7 comments
sayrer

@tolmasky it's a classic. the “next link” should always be a hash of the next posts, and unpredictable. also, some dumbass always says "this is complicated, can't we just use numbers” There’s always someone with a PHP script that can increment an integer!

Niki Tonsky

@sayrer @tolmasky why should it be unpredictable? What’s wrong with guessing next link?

sayrer

@nikitonsky @tolmasky you can write a bot to fetch them all without reading them.

Niki Tonsky

@sayrer @tolmasky well, first, you can write bot either way.

Second, what’s the problem with that?

sayrer

@nikitonsky @tolmasky it's because it is a natural rate limiter (they have to parse the response to get only one next link). This is not a security mechanism, just cost savings. Old content is more expensive to serve than new content, this is how Twitter, IG, and even Netflix work. There is a computer in my local ISP that holds the current popular movies. Same idea, but for the Redis or edge server that powers your website.

Miguel de Icaza

@tolmasky this is an brilliant insight I could have used 24 years ago.

Jan Lehnardt :couchdb:

@Migueldeicaza @tolmasky you can still fix it, those URLs currently don’t mean anything. :)

Go Up