Skip to content
loading...

What Happens When A User Edits A Post on Dev.to?

twitter logo github logo ・1 min read  

I am catching up on Ben's posts on web perf and I still don't quite get what happens when a post is edited. I understand that things are cached but doesn't that mean that if a post is edited it will take an unpredictable amount of time to update to CDNs all around the world? What are the best practices around this? Does it cost anything to do this? These are the kinds of questions I have when wondering about what I would run into if I were to make a dev.to clone.

twitter logo DISCUSS (8)
markdown guide
 

doesn't that mean that if a post is edited it will take an unpredictable amount of time to update to CDNs all around the world?

Yes, but once it hits the CDN, everybody gets the new copy. It's a matter of knowing that there will be a high read-to-write ratio to justify the strategy. Any post will get many orders of magnitudes of reads for every write. Under some circumstances we also make use of "stale while revalidate" where users see the stale version until they see a fresh version. We don't do this on article pages where we owe it to the author to not show stale, but in some places it's perfectly fine.

But on top of that, requests that hit the origin aren't that slow.

 

I am hardly ever happy with my posts no matter how many times I read them, so I edit a lot. I frequently see cached copies of my posts. Even after I Ctrl-F5 to see the updated copy. When I go back to it thru notifications, I'll get the original copy again. (Mainly applies to comments, I think.) I always wondered which version others were seeing, but I assume it was the very first one.

I also notice that sometimes I see an edit link on my comments, and sometimes not.

 

I also see this a lot. In fact, just today I was thinking I should send in a bug report to Ben and the team. Thanks for calling this one out.

Thanks a lot. This was a case where I'm not surprised it happens but grossly misread the frequency. Knowing this will definitely help us prioritize this. A bug report detailing where exactly it happens would still be appreciated.

It happens pretty reliably like this:

  • write a post or comment and publish it.
  • edit it and publish.
  • someone else likes your post.
  • go to the Notifications screen.
  • click the post that was liked.
  • after a long delay, the original (unedited) post is displayed.
 

Thanks for the heads up. I think there are some cases we are not properly handling. We'll get it worked out.

I also notice that sometimes I see an edit link on my comments, and sometimes not.

Yeah that's a known bug we're working on.

Thanks for feedback Kasey.

No worries man. Y'all do a great job. And after all:

There are only two hard things in Computer Science: cache invalidation and naming things.

-- Phil Karlton

 

thanks Ben! There are tradeoffs to make for sure. I think part of my hesitation is analysis paralysis. Having someone like you be transparent as to how you do things really helps (in case I need to do this in future)! thank you!

Classic DEV Post from Jul 21 '19

What's hard about React Hooks for you?

React Hooks are amazing, but require a learning curve... What's it been like for you?

shawn swyx wang πŸ‡ΈπŸ‡¬ profile image
Infinite Builder πŸ‘·πŸ½β€β™‚οΈI help people LearnInPublic β€’ more at http://twitter.com/swyx

Don't ghost on us ❀️

Join dev.to