castiron / manifold-marketing

0 stars 0 forks source link

Bm 78/rss #121

Closed blnkt closed 6 years ago

blnkt commented 6 years ago

Implements Rss Feed Blog Posts as a content element where you specify the site url (http://blog.manifoldapp.org), the feed url (http://blog.manifoldapp.org/feed/), and how many posts you want (3 for the time being). In the Content Element model we look to grab the posts from the Cache if present and if not we save to the Cache and store for an hour so they're available on the next page load. Includes HTML comments in the markup to indicate whether the blog posts are coming from the cache or not.

zdavis commented 6 years ago

What happens if the RSS feed isn't available? Test it with an invalid URL (to simulate the blog being offline). Make sure that in that case the HP still works. Ideally the content element just wouldn't render—we definitely don't want to get a 500 error or an exception.

Please also increase the cache time to 6 hours.

Thanks!

lthurston commented 6 years ago

A thought: we could also fetch the actual feed in the background (using October’s task scheduling), so the frontend doesn’t have to wait on a secondary HTTP request. Likely a rare case, but if the blog is ever offline and the cache expires a user will be waiting for that secondary request timeout before the page loads. I could assist with this today.

On Dec 29, 2017, at 6:41 AM, Zach Davis notifications@github.com wrote:

What happens if the RSS feed isn't available? Test it with an invalid URL (to simulate the blog being offline). Make sure that in that case the HP still works. Ideally the content element just wouldn't render—we definitely don't want to get a 500 error or an exception.

Please also increase the cache time to 6 hours.

Thanks!

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/castiron/manifold-marketing/pull/121#issuecomment-354454262, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMX5nfrqB8tZJ3PJpcPH4PTmbavEtvxks5tFPongaJpZM4ROyRL.

zdavis commented 6 years ago

Agree that background is better. If it's easy, great — I went with the just in time + caching approach in order to get it done by Tuesday.

lthurston commented 6 years ago

Ok, if we can get in done quickly — and I think we can — we’ll implement it. If Blake has a ton left to do, I can just do it myself.

On Dec 29, 2017, at 7:43 AM, Zach Davis notifications@github.com wrote:

Agree that background is better. If it's easy, great — I went with the just in time + caching approach in order to get it done by Tuesday.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/castiron/manifold-marketing/pull/121#issuecomment-354461705, or mute the thread https://github.com/notifications/unsubscribe-auth/AAMX5imOuncvP1ZEpJ-yePWMrV1fzCxtks5tFQi7gaJpZM4ROyRL.

lthurston commented 6 years ago

I did some stuff. Fetching of the RSS feed now happens only in the background. You can run php artisan rss:fetch or set up the scheduled task to run it automatically every five minutes. I wrote the fetcher in such as way as it should start trying to get the feed again before the actual cached feed data expires, thus preventing any race conditions between cache and page requests.

I haven't totally figured out the task scheduling -- it's behaving a little odd for me locally, and I'm not sure if it's actually running the fetch command, but we can figure that out quickly on Tuesday I think.

The RSS feed output on the frontend contains an HTML comment that says how long in minutes until the cache clears, which might be useful for debugging / verifying that it's working.

One thing we might want to add is caching of fallback data -- posts data that doesn't expire in case the blog is down for a longer period of time. It's so easy, that why not?