-
Notifications
You must be signed in to change notification settings - Fork 52
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
How to automatically create cachep2p.security.js? #26
Comments
Hello @extensionsapp Currently there is no way to automatically create the cachep2p.security.js but it could be easily achieved by reading your sitemap, getting each url content using a library like request and then using simple-sha1 to obtain the security hash of each URL and saving them into the cachep2p.security.js file. |
Hash from the URL or from the site content?
OR
|
The content of each url (second option) |
Thank you, Carlos. I'm going to try now. |
I use ExpressJS.
Console.log:
Why another hash? |
Compare document.documentElement.innerHTML in the browser with what you have in ExpressJS |
Browser auto add Ohh, I have many elements on website. Every restart - new hash. Browser/server:
innerHTML:
I use https://github.com/kangax/html-minifier Can I switch to creating a hash based on the URL? |
Can I pass the hash of the page on the server in the tag? And |
Oh, I think I realized that nonsense said. The hash is created from the data. |
Ignoring the social network, the only difference is the "" ? |
No, many removed - comments, whitespace, quotes, min css, min js, etc. https://github.com/kangax/html-minifier
|
And can't you hash the result from that minified text instead? |
Server code:
4bf59c219f7eb1278b15b82d25490e1130a1a7ff Min server code === browser code (Ctrl+U - view-source:https://...):
c8e2912b026c5ccf34ba00339b3fe45ff0189a85 browser code !== document.documentElement.innerHTML
2d78c678d2b4e2a7b5833ad8209151a39adcc5ae |
And if create hash from RequestJS -
Result:
c8e2912b026c5ccf34ba00339b3fe45ff0189a85 |
I understand, I guess that one solution would be to use cheerio to get the same content of document.documentElement.innerHTML in the server side |
Good idea, @guerrerocarlos
Do I have a bug in the browser? How can I check if the cache is working? With each page update, the site accesses the server. And I just noticed. Hash in Opera browser is different. |
Oh, even having the same HTML-code in the browser and on the server, the hash is different.
This code |
Are there any thoughts about this error? |
Hello.
How to automatically create cachep2p.security.js?
I have a sitemap and on the basis of these data create cachep2p.security.js.
How can I do that?
The text was updated successfully, but these errors were encountered: