A
A
Artur Kogut2015-08-14 15:22:20
MySQL
Artur Kogut, 2015-08-14 15:22:20

Node.js based templating engine with object storage in MySQL and post-processing in webkit?

Hello.
I want to try to implement a template engine based on a database. Practically, reinvent the Web. The idea is this.
1. When requesting the /index page, node.js returns only the head, from which init.js is executed (a user script on the client side).
2. init.js requests GET /index?init.
3. node.js checks if the page exists in the page table.
4. node.js queries records from the node table, where `node`.`page` FK `page`.`uri` = index and `node`.`parent` = 'body'.
5. node.js fetches something from the database and gives the objects of the first nesting level in this form: [header: [class: ['header', 'object`]], main: [class: ['main'] , role: 'main', id: 'main']].
6. The request is cached on the client side and the next time init.js will request /index?init with an If-Modified-Since header.
7. init.js builds the DOM from the objects it receives and asks for the next level for each one. For example, GET /index?header.
8. node.js renders each of the blocks, as in point 5.
What is the point:
1. Make HTML more OOP.
2. Cache the page by elements, styles by classes (requests are cached, some data can be cached in indexedDB).
3. Transfer blocks in parallel over one persistent connection using HTTP/2.
4. Instead of interval checking for changes in blocks on the client side, send new blocks from the server using HTTP/2.
5. Ability to view the page without an Internet connection.
And much more.
Questions:
1. How best to store the DOM. What is the best way to store a sample template from DOM elements (I plan to use indexedDB on the client side)?
2. Will search engines index such pages loaded via AJAX?
3. How to store innerText, because a block can be inserted in the middle of it?
4. Should I duplicate the blocks for each of the pages or keep only the original ones?
5. How suitable is mySQL for such a task? Can it be replaced with indexedDB followed by caching into objects on the server side?
6. Will node.js be able to handle, say, 100,000 block requests from 1,000 clients per second? What server configuration is needed?
7. The question arises how to store dynamic values. But what if, for example, we connect webkit to node.js and immediately insert the block received from the base into the body. Add the data-post-action attribute to the blocks in which you want to insert a dynamic value. And catch the event of creating a DOM block with certain data-post-action?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
T
Timur Shemsedinov, 2015-08-14
@MarcusAurelius

Want to reinvent the web?
1. Get rid of the DOM, replace it with components, like in Delphi and .NET. In general, HTML and CSS are very bad technologies for applications that set us back two decades.
2. Get rid of HTTP, move to RPC, this is convenient for connection-oriented client-server applications, where interaction is through: remote procedure calls and event broadcasting.
3. Get rid of relational DBMS and store objects without decomposition, building indexes around them for fast search in collections.
And may Allah help you!

V
v- death, 2015-08-14
@vGrabko99

I think it is not necessary to fence such a perverted bicycle. Plus, it's faster to give from the disk than according to your scheme.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question