Introduction
Let me just start by saying that this is a very difficult problem for me and I've been coding professionally for 5 years.
Use Case
Zillow has implemented this design pattern successfully. If you type something into the search box and hit enter, it takes you to a search result page. If you click on one of the results, the URL at the top changes and a modal pops up with information about the home you just selected but the page does not refresh (probably React.js).
Important: If I copy the URL and paste it in a new browser, the listing shows up along with the other results for whatever I searched for
Thoughts...
Now, consider this for a moment: There are millions of listings on Zillow. Let's just use this one as an example.
The URL is pretty long. It looks like this: https://www.zillow.com/homes/for_sale/Old-Town-ME/84999468_zpid/6306_rid/45.005107,-68.629017,44.895403,-68.813553_rect/12_zm/
Those folders are pretty deeply nested.
Questions:
Are there actually just billions of folders on the server?
One for each ID of every type of item they track on top of one folder per each position on the map?
Actual Case
I have a React web app that I'm working on and for a while, I couldn't get the application to load when a request was made to the server for a specific route. At the present moment, you can actually find a development version staged on the internet here.
Note that my temporary solution (you will read about this below) has not yet been implemented in the staging environment yet
When you search for something it takes you to the search results page, but if you refresh, you get a 404 from the server. The server thinks you're either looking for a folder titled "search" or just some arbitrary file with the same name.
So, this is what I did and it works "in theory."
I made a folder named "search" inside the root directory, copied the application and pasted it into that folder, made it so that the URL reads "/search/" when the users submits a search (looks like: this.props.history.push('/search/')
), and then made a few modifications to the App to make it so that the search value is stored in localStorage
. Now, in theory, when you make a request to http://www.spyro.world/search/ you get the copy of the application that gets the search value from localStorage
.
Now, I realize that this is probably just horribly wrong. Let us continue.
So, now I'm faced with this problem where if I want to do separate URLs for each listing and I want the app to load correctly when a user copies the URL from the top of the browser, I would have to make one copy of the app and place it in a unique folder for each listing. I have some 20,000 listings at the present moment.
Questions:
Am I right?
What am I doing wrong?
How can I make it better?
Is there such a thing as a node.js web hosting server?
Is there a way to tell the server it's a React route and not a request to a folder?
Aucun commentaire:
Enregistrer un commentaire