Imagehoster cache purge for Cloudflare

in HiveDevs3 years ago (edited)

Quick post about new script that helps with caching avatars on imagehoster instances hosted on Cloudflare.

ecency-imagehoster-caching

We have 2 imagehoster instances right now, one run by Ecency team and another from Blocktrades team. It is crucial part of platform without which user experience would really suffer. Images, avatars are face of every UI.

https://images.ecency.com
https://images.hive.blog

They both run in front of Cloudflare and images were not utilizing Cloudflare cache properly. For couple reasons, one - avatars cannot be cached for long time, when person updates avatar via apps/websites then they expect it see it instantly, two - Cloudflare considers them dynamic content by default.

If you force cache avatars with Cloudflare page rules then update only shown after cache is expired. That’s not acceptable for Blockchain that’s very fast but avatar update require cache expiry. On Ecency instance we had 10 seconds cache, while Hiveblog instance wasn’t using cache at first and couple days ago Blocktrades tried 4h. All other images could be cached for longer period because they don’t change at all, for avatars 4h. Which was still too long.

To solve avatar caching issue, created simple script that would purge cache from Cloudflare when account gets update on blockchain. If imagehoster instances are down or in maintenance, all images would be served from Cloudflare cache which is really great for user experience as well.

If you will be running Imagehoster instance in future or considering it, I would recommend running this script on separate server and set avatars caching to longer period safely. If you are not using Cloudflare, then consider removing caching avatars completely, it will put some load on your server but alternative is confusing user experience.

https://github.com/ecency/cf-cache

Both instances running above script now and whenever account update triggered on Blockchain, above script purges relevant user’s avatar to keep it fresh, use new avatar on all apps that depend on it.

images.ecency.com cache period for avatars 1 week
images.hive.blog cache period for avatar 5 hours

After change, I noticed Ecency.com became even more faster... Caching images for sure improving performance of all apps.

Support proposals

Ecency | Hivesearcher | Hivesigner

Sort:  

Losing the images is not great as happened recently. Hope you can find solutions that work for us. Cooperation between the dapp teams is vital to get the best results.

Could you elaborate or remind, where/when losing images happened or circumstances around that incident?

Last time was last Friday morning (in UK). Profile images and most of those in posts were not visible for at least a couple of hours in peakd and hive.blog at least. I saw people reporting that they could not upload images on various discord channels. This has happened before. I assume that eventually someone was available to fix it and it was okay later on. That is all I know.

The images are not gone. There simply don't load on the front ends because of the CDN.

I assumed they were preserved as they came back, but not having them visible confuses a lot of people. I realise that making the system resilient is hard. We saw a lot of big sites taken out totally by a CDN issue recently. Hive dapps have limited resources to pay for expensive services, but I know we have some clever people working on solution.

Ah, it was only on those frontends, ecency.com didn't have any problems since it is using other instance.

Great 👍 dear

Love to be here in ecency.com.

Goodjob !
Hopefully @good-karma alwasy arround us

How can we help?

Good to hear that you're working on performance constantly :) 😎

Always 😊 That's the one thing, I like the most website that's fast and responsive.

Agree. I like, too. 😎

Super fantastic

Congratulations @good-karma! You received a personal badge!

Happy Hive Birthday! You are on the Hive blockchain for 5 years!

You can view your badges on your board and compare yourself to others in the Ranking

Check out the last post from @hivebuzz:

Feedback from the July 1st Hive Power Up Day - ATH Volume record!

It is good to know that you are constant at work. The application is always growing. Thanks for the work you are doing

@good-karma @ecency I have seen a bug on the points, might be a frontend only bug though, but I think it is important to report privately to you. I am afraid people might exploit it.

My discord is igormuba#6942

Any preferred way to contact you? Sorry for coming here to ask about it. Thank you.

Thank you, yes discord is always good place to report or via email: [email protected]

Thaks your upvoted!! Have a nice day.

Thanks your upvoted. Good day!

Your post is interesting and allows you to better understand the principle of the avatar

Friend greetings from Venezuela, I hope to have your good vote, I am surviving here the very hard situation

@good-karma how can I direct message you?

Thank you for taking the time to upvote my posts. I'm new to Ecency and I must say I am really enjoying it. I still have alot to learn but this app has helped me greatly👌
I'll be converting all my friends from Facebook and Instagram that has no idea that this platform exists. We have been missing out big time.

@good-karma, The links are broken!

which links?

Those 2 links here seem to have an issue:
on https://images.ecency.com and
on https://images.hive.blog, on the landing pages that's what we get:


Thanks for what you do @good-karma !

Sorry again @good-karma, with Linux Fedora we have issues too, with vessel hive ecency and peakd desktop versions on hive code lines it shows a bug when trying to open a file, I remember "scrypt" but not sure. vessel and ecency's appimages just don't open. Maybe incompatibility? just thought could mention it.

That might be incompatibility. I will take a note of this and we will check. Thank you.

As for images links, that's ok and good pages, both instances run different modified version of imagehoster basically.

Thanks to you for making all this possible!

Hello @good-karma.

Is there any way to recover lost keys because I have lost my keys and only left Active Key.

You will need to do account recovery, do you remember owner key?

No

Hmm in that case, unfortunately there is no way to get full access to your account. But if you have your active key, then you can do almost all actions required for your account, transferring funds, etc.