jinty / prerender-cloudfront Goto Github PK
View Code? Open in Web Editor NEWprerender.io cloudfront example middleware
License: MIT License
prerender.io cloudfront example middleware
License: MIT License
Thanks for making this repo. I've had a few people use it so far and say it works great!
One thing I noticed is that the URL isn't checked for _escaped_fragment_
so the crawlers that currently support it (Googlebot for now, Bingbot, and Yandex) are not served prerendered pages.
That should be a pretty easy check to add just before here.
Either that, or Googlebot
, bingbot
, and Yandex
user agents should be added to the default list of user agents being checked. John Mueller has stated that as long as your prerendered content you serve back to Googlebot based on a user agent check is identical to the page your users see, you won't be penalized for cloaking in that case: https://groups.google.com/d/msg/js-sites-wg/CkLSG3TxxK0/LSJtiDxNCwAJ
The Cloudformation template has:
Runtime: "nodejs6.10"
But as of June 4th, 2019 the currently supported Lambda runtimes for Node are:
nodejs8.10
nodejs10.x
https://docs.aws.amazon.com/lambda/latest/dg/lambda-runtimes.html
I don't think modifying the runtime would change anything but wanted to put that out there first.
It seems like the setup is not able to pass querystring to prerender.io?
Because we are passing this as the final path: [{ key: 'X-Prerender-Host', value: host[0].value}]
So let's say I want to prerender https://www.example.com/product?id=1
, the final rendered page will be https://www.example.com/product
because it's not passing the query string
Hello!
I would like to apologize if this questions have been already answered before, but I am having an issue using cloudfront + pre render.
When google bot/others bots do the request for website, cloudfront is caching prerender html response and always delivering HTML content, does not matters if the request is coming from a browser or a bot.
The question is: How can I tell cloudfront to not cache content if the response is pre rendered html? I think will be something as the project described in this quote:
"As prerender.io does NOT want any Cloudfront caching (see prerender/prerender#93 (comment)) we disable that by including a X-Prerender-Cachebuster header which effectively disables cloudfront caching."
Anyone has faced same problem and found out a solution? Everything is working fine except this strange cache behaviour.
I will keep searching and If I found a solution I will update this issue.
Many Thanks!
will fill the common usecase and be a more reliable example.
I followed through each of the steps in attempt to test if this working and after everything is completed, the website works as expected when viewed in browser or curl request without header but when I send a curl request with the user agent header, the html that is returned doesn't contain any script tag and the content still says: "Loading from javascript..."
I would like to implement this as a solution for my current site, however I'm not certain how to use the example as it sits. Is there a installation guide that would walk me through implementing on an existing S3 CloudFront hosted site?
The lambda testing wheter to set the header for prerender.io or not isn't currently testing:
WhatsApp/2.19.81 A
).json
files.map
filesOptionally don't cache responses from prerender.io
Hi, we implemented this for our site and for some users it seems to provide the correct page for others it returns a message saying "Sorry we cannot seem to find the page you are looking for". It appears that the lambda considers normal users as a bot. Can you please suggest, what can be done to fix this issue.
I have attached couple of screen shots
After a lengthy conversation with AWS support, they came to the conclusion that you cannot have a CloudFront distribution in front of an Amplify App that also uses a CLoudFront distribution. This is true for Apps that are running Next.js with SSR, as we are.
AWS confirms that presently there is no solution to utilize prerender.io with Amplify in this fashion. From AWS support:
Hello,
I did have a discussion on this with the Amplify Console team, and they confirmed that conclusion.
Support for prerender.io is currently not possible via an Amplify hosted SPA . There are 2 reasons for this (based on the CloudFront example from the GitHub ticket):
We don't associate any ViewerRequest Lambda@Edge with the managed CloudFront distribution, so we won't be able to add new headers based on the user-agent, query_string etc. before the request reaches the CDN.
Even if we were to workaround that by handling everything beyond the CDN (The customer would still have to work with a 2 second TTL), we don't have a way to achieve a redirect to any prerender.io server since our OriginRequest Lambda@Edge implementation does not support this customization.
Now support for this may be added in the future as it has been something that has been requested by previously as well. Periodically check the release history on the Amplify Console GitHub page for the latest supported features [1].
Please reach out if you have any further questions.
References:
[1] https://github.com/aws-amplify/amplify-console
We value your feedback. Please share your experience by rating this correspondence using the AWS Support Center link at the end of this correspondence. Each correspondence can also be rated by selecting the stars in top right corner of each correspondence within the AWS Support Center.
Best regards,
Daniel S.
Amazon Web Services
Hello. This repo is very helpful. Thank you.
I just want to tell about X-Prerender-Cachebuster. CloudFront respects Cache-Control header from Lambda@Edge functions. I set Cache-Control: no-cache, no-store
in my origin-response function and works fine for me.
https://aws.amazon.com/premiumsupport/knowledge-center/prevent-cloudfront-from-caching-files
Hope this helps.
AWS cannot create this stack anymore because nodejs.10x is no longer supported when creating new lambda functions. AWS recommended to change this to nodejs14.x, which I did, and it worked.
Hi, followed your code exactly. Problem is, it works immediately after publishing and doing invalidation, but within 12 hours, cloudfront serves the pre-render version regardless of whether you are browsing from a bot or a normal browser. Clearly an issue with cloudfront cache as it worked for a short time. Can you advise?
I'm having an issue with images and css not loading for bots. If I'm understanding the issue correctly, the request at the edge location sees the user agent is a bot and sends the request (by passing cloud front cache) to the prerender server, it renders the page, caches it and returns the result with the full html.
When an image or css is with-in the HTML it's requested, the edge location sees it's a bot and sends the request to the prerender servers. But the prerender servers do not cache the assets.
All our assets are relative urls. Not sure if I just have something mis-configured or if the redirect needs to exclude redirection of assets.
Hello, I am writing this question here because i found nowhere else to ask this.
Is there any way to configure this to redirect clients and crawlers both to the prerendered page. I mean to serve the prerendered site only. I tired keeping prerender=true in every case but that doesn't serve the page and doesn't cache it either. Any help is appreciated.
We are hosting a React single page app via AWS Amplify and need to serve crawlers (like Google search crawlers) a pre-rendered version of each page for SEO reasons.
I came across this repo here and wonder if anyone knows how would I go about configuring AWS Amplify to use it?
Thanks
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.