nuxt-community / feed-module

Everyone deserves RSS, ATOM and JSON feeds!
MIT License
226 stars 36 forks source link

Question: What is the feed-module for? #60

Closed connecteev closed 4 years ago

connecteev commented 4 years ago

This module looks interesting but I'm not sure what it's for. What is the benefit of this feed package versus calling axios to retrieve feeds directly? Is caching the only benefit here?

  1. How is the feed retrieved periodically? Also
  2. What happens when the cache expires and I am On a page using the feed? What happens when the cache expires and I am NOT on a page using the feed?
manniL commented 4 years ago

If you want to include RSS/ATOM/JSON feeds on your page, then you need a URL representing it. It either serves a static file or triggers a serverMiddleware to fetch.

Generated Page

The feed will be rendered as file in the set format and will be available in the dist folder and therefore on the website.

  1. It'll be re-created on build
  2. Not applicable

Dynamic SSR

A serverMiddleware will fetch the feed and display the content dynamically

  1. https://github.com/nuxt-community/feed-module/blob/master/lib/module.js#L37-L44 (display cached result or re-fetch if stale)
  2. If on page - nothing. If not on page (and then requesting the feed), it'll refetch the content.
connecteev commented 4 years ago

Very interesting....bookmarked for me to look into this :) Thanks @manniL!

connecteev commented 4 years ago

@manniL One question here for you! I am using Nuxt in Dynamic SSR mode.

Say I was creating:

  1. a news feed like Facebook (which is personalized to the logged-in user and changes every hour)
  2. a relatively static feed that changes every 2-4 weeks.

I am currently triggering an Axios request every time the page is loaded. Would this feed-module help in one or both of the above scenarios and how /when do you recommend using it? Thanks in advance..

manniL commented 4 years ago

The feed module could work for both, though the 2nd use case is probably easier to implement.

connecteev commented 4 years ago

@manniL thank you for the clarification. Can the feed module be used with infinite scrolling? Any examples of this (in codesanbox or github) would be great.

I found https://github.com/HendraPB/nuxt2-infinite-scroll (demo here ) but it turns out this does not show the feed results if you view source, so SSR doesnt work.