nextjs dynamically set response header [duplicate] - next.js

This question already has answers here:
how to cleanly handle errors in nextjs getStaticProps
(2 answers)
Closed 12 months ago.
I'm trying to create a blog for my website. Because I want to be able to dynamically add blogs without rebuilding I had to choose between incremental static generation and server-side rendering. Because a blog page won't change often, I decided to go for ISG. Of course, not every blog ID is a valid page. Therefor I want to set a status code, but I can't find out how without using server-side rendering

I found the answer. Turns out I can return notFound: true from the getStaticProps to get a 404

Related

Revalidate key in Next.js [duplicate]

This question already has answers here:
How does the revalidate process in Incremental Static Regeneration work?
(2 answers)
Closed 7 months ago.
As you know, we can update SSG page via revalidate key in getStaticProps() and user at firstly see latest content and after refresh page twice can see updated content.
But is it proper that user should refresh page twice? In my opinion, user do not know should refresh twice. However, new users can see the new content at first.
I would be appreciate if share your comments about revalidate.
You'll usually have more than 1 user. The Re-generation can be triggered by any of your users so not everyone on the site needs to refresh twice. Only 1 user would do that.

Is there any Better way to reflect the changed CSS code on user end rather than telling them please clear your cache to see the update? [duplicate]

This question already has answers here:
Force browser to clear cache
(21 answers)
Closed 2 years ago.
I have a website. When I Change something to the style sheet the effect does't fall into user's browser.Then when they clear their cache that new style sheet reflects to then.So my is there any better way to reflect that change whenever I update my code ??
My go-to solution would be to set the Cache-Control header's max-age to something like 5 mins. That way users navigating on your page don't have to load the stylesheet each time, but when they come back like an hour later, it is reloaded.
Another way would be to increment a version number as a get parameter on the end of your stylesheet url each time you make changes to the stylesheet:
<link href="/styles/home.css?version=1" rel="stylesheet">
When you increment the version number, the browser thinks it's a different resource and reloads it.

Adobe AEM WorkFlow activate a page including child pages [duplicate]

This question already has answers here:
How to replicate a page and all its children using replicator API?
(2 answers)
Closed 7 years ago.
I want to activate a page also include it's child pages using workflow
like below
Parent Node
・Child Node 1
・Child Node 2
・Child Node 3
Requirement is:
Is it possible ??? Please give solution also in comment......
thank you very much!!!
You can use the Replicator api to activate the pages.
In your workflow process step. You can do the following
currentPage = getCurrentPagePath(); // this is something which you have to figure out, this depends on your workflow code i.e how exactly your workflow got triggered.
Now,
Iterator<Page> childPages = currentPage.listChildren();
Now iterate over the child pages and for each child page, do the following
replicator.replicate(session,repplicationActionType, childPagePath);
You can get the instance of replicator using OSGi dependency injection.
#Reference
public Replicator replicator

Can a URL start with "//"? [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Is it valid to replace with // in a <script src=“…”>?
We have a site on http[s]://A.example.com/ that references some resources (JS and CSS) on http[s]://A.example.com/
It makes sense, and avoids some browser warnings, if the same scheme is used when referencing the resources as the main site A is using. Site A uses PHP, so we can programmaticly detect the current scheme (http or https) and insert that into the header of the page.
However, we have found that just using '//' instead of the scheme also works.
So site A may reference "//B.example.com/theme/main.css" without a problem in all browsers we have tried, regardless of whether we go to site A using http or https.
My question is: is this a valid URL? It seems to work, but I cannot find anyone else doing it, and I cannot find any examples of this being suggested or recommended.
Yes. It is called a protocol-relative URL. See also Can I change all my http:// links to just //?

what is the purpose of a css link placed like this style.css?23409823098 [duplicate]

This question already has answers here:
Closed 14 years ago.
Duplicate of what does do in a css link
I've seen a few sites who list a stylesheet with parameters in it.
does anyone know what its called and what purpose they serve?
ex:
href="fonts.css?1169659562000"
The parameter is changed every time the content of the file changes. This allows the site hoster to set an infinite cache timeout, which keeps the browser from re-requesting the CSS. Without the parameter, updates would never reach the client.
See also the Stackoverflow Podcast #38 and the YSlow tool.
To force the browser to refresh the CSS link. It's more reliable than expires headings and the like.

Resources