Understanding route handler
Answered
maslomeister posted this in #help-forum
Hi there, i have a route handler to get reveiws from external resources
then i use it in my client component like this
when building my app i noticed that this route handler is built as a static page
Does this mean that all fetch request that are happening inside of this route handler are cached on build and then never refreshed or what?
then i use it in my client component like this
const { data, error, isLoading } = useSWR("/api/reviews/get_reviews", fetcher);when building my app i noticed that this route handler is built as a static page
â—‹ /api/reviews/get_reviewsDoes this mean that all fetch request that are happening inside of this route handler are cached on build and then never refreshed or what?
Answered by B33fb0n3
@maslomeister that means, that the code inside the route handler don't change. Static = no code change. Dynamic = Code change through dynamics parts like parts in the url or params or ...
4 Replies
@maslomeister that means, that the code inside the route handler don't change. Static = no code change. Dynamic = Code change through dynamics parts like parts in the url or params or ...
Answer
Even if you have "no code change" you can still get different results. For example when you fetch a external api. The code inside your route handler stays everytime the same, but the results from your api can change