Comments (4)
It's doing a full refresh 'cause you're using getInitialProps
in your _app.js
file right?
from krabs.
Yes.
App.getInitialProps = async ({ Component, ctx }) => {
const tenant = ctx?.req?.tenant?.name;
let pageProps = {};
if (Component.getInitialProps) {
pageProps = await Component.getInitialProps(ctx);
}
return {
pageProps: {
...pageProps,
tenant,
},
};
};
export default App;
from krabs.
Using getServerSideProps
aswell as getStaticProps
has the same effect.
export async function getStaticProps({ Component, ctx = null }) {
const tenant = ctx?.req?.tenant?.name;
let pageProps = {};
if (Component.getStaticProps) {
pageProps = await Component.getStaticProps(ctx);
}
return {
pageProps: {
...pageProps,
tenant,
},
};
}
Could you provide an example on how to solve this?
from krabs.
By using getInitialProps
in your _app.js
file, you require a full SSR for each page in your application. As for now, there's no way to avoid this behavior, but I have a suggestion: use a CDN such as Akamai or Cloudflare for caching your pages after the first render, and use their APIs for invalidating the cache manually or time-based (just like an "enhanced" ISR).
If you feel like wrapping your application behind a CDN is a bit too much, maybe Krabs it's not 100% needed 🙂 it is supposed to work on large-scale projects where a good caching layer is required anyway!
PS. I'm currently running Krabs in production on a two-domain application, and even if I SSR every single page, its performances (cache apart) are outstanding, and that's because Next.js is really well made.
from krabs.
Related Issues (20)
- Fix GitHub CI workflow HOT 1
- Error trying to set up kraber HOT 3
- Tenant url does not work locally HOT 2
- Router push takes subdomain name? HOT 2
- How to add a CMS like Strapi HOT 1
- Guide of how to deloy this HOT 2
- Next.js internationalized routing support
- public folder items not accessible HOT 1
- Slugs not working? HOT 1
- rewrites dont work HOT 4
- How to use Krabs in Production HOT 1
- Custom response for unlisted tenent HOT 1
- 'Common pages' functionality HOT 3
- Trying to add _middleware at pages directory doesn't work.
- API Routes HOT 1
- Example project does not work HOT 3
- problem start server.js
- How to tenants for subdomains or custom domain in the production?
- nextjs 12.3.0 - Error: Cannot find module 'colors' HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from krabs.