225 posts
  • Beta Tester
  • Bought between 1 and 9 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 and 100 dollars
clinton says

Hey Guys & Gals,

After adding this feature, then removing it, then adding it, then removing it, I have added item comment editing for the third and hopefully final time. (Fingers crossed.)

For those web-developers who are interested, here is the problem that we were having:

We cache item comments because the popular item pages make up a very large portion of our traffic. This speeds up our item pages by about 10x on average.

The item comments page looks different depending on whether you are logged in (extra Flag Comment links), if you are an admin (extra admin links) or if you are not logged in (no links). In the past we were caching 3 different versions of the page for logged in, not logged in, and admin. This is not ideal from a memory perspective, but it really helps performance.

Of course, adding in an Edit link doesn’t play nice with caching because we should only show the Edit link to the person who made the comment, and only for our allowed time window. This is what caused our first failed version of comment editing, a failure to notice that it would not work with our caching.

To fix this I started caching just the data and rendering the HTML , including the relevant Flag Comment, Edit links, on each request. Unfortunately this was nowhere near as efficient as the cached HTML because Ruby/Erubis just isn’t that performant. Bummer. That was our second failed attempt. Rolled it back after about 4 hours because the drop in performance was going to kill the whole site during our peak.

So, finally, my last attempt at caching the item page with comment editing. I went back to caching the HTML of the Item page, but I also cache the underlying data. The majority of the page (the doughnut) is prerendered HTML , with little markers (‘doughnut holes’) where I have to fill in dynamic content depending on the logged-in user. (The Flag Comment, Edit links). The final result is what is presented to the user. So far this approach seems to be working okay, not quite as fast as our old caching, but at least we have the comment editing feature now.

Oh, and we are not caching the comment date any more either, so it doesn’t constantly say ‘1 minute ago’ for the latest comment. Hooray for Doughnut Caching.

86 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
YA says

Great! I think this feature is very useful! Thanks.

1633 posts fueledweb.com
  • Envato Staff
  • Reviewer
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Author had a Free File of the Month
  • Bought between 10 and 49 items
+4 more
RimmonTrieu Reviewer says

clinton, it seems that I can’t even post comment anymore ?

1417 posts
  • Envato Staff
  • Has been a member for 5-6 years
  • Senior Reviewer
  • Sold between 10 000 and 50 000 dollars
  • Attended a Community Meetup
  • Contributed a Blog Post
  • Contributed a Tutorial to a Tuts+ Site
  • Exclusive Author
+10 more
kailoon Reviewer says
clinton, it seems that I can’t even post comment anymore ?

I cant post comment on any item page too..

86 posts
  • Author had a Free File of the Month
  • Bought between 50 and 99 items
  • Exclusive Author
  • Has been a member for 5-6 years
  • Referred between 10 and 49 users
  • Sold between 10 000 and 50 000 dollars
YA says
I cant post comment on any item page too..

Hmm… I’m having the same issue

188 posts
  • Microlancer Beta Tester
  • India
  • Exclusive Author
  • Elite Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 5-6 years
  • Referred between 200 and 499 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 more
settysantu says
I cant post comment on any item page too..

facing same issue.

3146 posts Point. Counterpoint.
  • Senior Reviewer
  • Envato Staff
  • Has been a member for 7-8 years
  • Won a Competition
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
  • Canada
  • Attended a Community Meetup
+7 more
ADG3studios Staff says

Looks OK here… Posted, edited, and deleted.

225 posts
  • Beta Tester
  • Bought between 1 and 9 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 and 100 dollars
clinton says
clinton, it seems that I can’t even post comment anymore ?

Thanks, Rimmon, you were correct. I was caching the ‘post a comment’ stuff so it would depend on whether a logged-in or non-logged-in user viewed the page first. I have fixed that. Hopefully that will be the last bug for this featre. (Still got my fingers crossed.)

225 posts
  • Beta Tester
  • Bought between 1 and 9 items
  • Exclusive Author
  • Grew a moustache for the Envato Movember competition
  • Has been a member for 6-7 years
  • Referred between 1 and 9 users
  • Sold between 1 and 100 dollars
clinton says
Looks OK here… Posted, edited, and deleted.

Hehehe, you were one of the lucky ones. All fixed now.

188 posts
  • Microlancer Beta Tester
  • India
  • Exclusive Author
  • Elite Author
  • Sold between 50 000 and 100 000 dollars
  • Has been a member for 5-6 years
  • Referred between 200 and 499 users
  • Repeatedly Helped protect Envato Marketplaces against copyright violations
+1 more
settysantu says

now working fine, thanks

by
by
by
by
by
by