Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Testing content-visibility: auto #1543

Merged
merged 4 commits into from
Feb 23, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
try content-visibility: auto
  • Loading branch information
wesbos committed Feb 23, 2023
commit 54086784a03780187111f50855f847942c7f782b
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
},
"scripts": {
"build": "netlify build",
"dev": "NODE_ENV=development remix dev"
"dev": "NODE_ENV=development netlify dev"
},
"devDependencies": {
"@types/styled-components": "^5.1.26",
Expand Down
5 changes: 1 addition & 4 deletions src/entry.server.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,7 @@ export default async function handleRequest(
) {
// check if we have a cached response in memory
const cachedResponse = cache.get(request.url);
const isBuildUrl = request.url.includes('/build/');
if (cachedResponse && !isBuildUrl) {
if (cachedResponse) {
// console.log('Serving from cache', request.url);
// if we have a cached response, check if it's less than 5 seconds old
const now = new Date();
Expand Down Expand Up @@ -64,15 +63,13 @@ export default async function handleRequest(
// tee the stream so we can cache it and send it to the client
const [toReponse, toCache] = body.tee();

if (!isBuildUrl) {
streamToText(toCache).then(html => {
console.log('Caching', request.url);
cache.set(request.url, {
html: html.replace('Rendered Fresh', `Rendered from cache ${new Date().toISOString()}`),
date: new Date(),
});
});
}

const headers = new Headers(responseHeaders);
headers.set("Content-Type", "text/html");
Expand Down
4 changes: 2 additions & 2 deletions src/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ body::-webkit-scrollbar-thumb {
grid-template-rows: 1fr auto auto;
}

.PersonWrapper:nth-child(5) {
background: green;
.PersonWrapper:nth-child(6n) ~ .PersonWrapper {
content-visibility: auto;
}

.PersonInner {
Expand Down