简体   繁体   English

渲染大型HTML页面

[英]Rendering Large HTML Pages

I am currently write large data to html for some periodic reporting reasons . 由于某些定期报告原因,我目前正在将大数据写入html。 It has just a table with about 10,000 rows . 它只有一个大约10,000行的表。 Which are getting large as 7MB . 哪个大到7MB。 When users open it sometimes browser becomes unresponsive cause of large file . 当用户打开它时,有时浏览器会因大文件而无法响应。

I can store JSON on server and later on when people load page get that JSON and page through and show 1000 records at a time. 我可以在服务器上存储JSON,稍后当人们加载页面时获取JSON并翻页并一次显示1000条记录。

What is better approach to implement this ? 有什么更好的方法来实现它?

I make the following assumptions 我做了以下假设

  1. the data is stored in a file 数据存储在文件中
  2. the data will only be appended to 数据只会附加到

If that is true, you can implement paging on the file. 如果是这样,您可以在文件上实现分页。 Use a random acces file. 使用随机访问文件。 Simply read the file line by line for a number of records. 只需逐行读取文件即可获得多个记录。 Then when you are done, save the file position . 完成后,保存文件position When sending the html data to the browser also save the file position. 将html数据发送到浏览器时也会保存文件位置。 This can be done using query parameter in a link to "get more data". 这可以使用“获取更多数据”链接中的查询参数来完成。

When the user clicks the "get more data" link, you reopen the file, but first position() to the saved position. 当用户单击“获取更多数据”链接时,您将重新打开该文件,但首先将position()置于保存的位置。 Then read the next few records, save the position etc. 然后阅读接下来的几条记录,保存位置等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM