1. Technical Field
Embodiments of the present disclosure generally relate to data processing technology, and particularly to a server and a method for loading web pages.
2. Description of Related Art
A web page may contain a large amount of data. Reading the large amount of data from a database at one time may consume a lot of time. Furthermore, to display the large amount of data at one time with a browser may cause a heavy burden to the browser. Therefore, there is room for improvement in the art.
The disclosure, including the accompanying drawings, is illustrated by way of examples and not by way of limitation. It should be noted that references to “an” or “one” embodiment in this disclosure are not necessarily to the same embodiment, and such references mean “at least one.”
In general, the word “module”, as used herein, refers to logic embodied in hardware or firmware, or to a collection of software instructions, written in a programming language. One or more software instructions in the modules may be embedded in hardware, such as in an erasable programmable read only memory (EPROM). The modules described herein may be implemented as either software and/or hardware modules and may be stored in any type of non-transitory computer-readable medium or other storage device. Some non-limiting examples of non-transitory computer-readable media include CDs, DVDs, BLU-RAY, flash memory, and hard disk drives.
The management unit 10 reads data (e.g., text, HTML, CSS) of a web page from the database 40 at a specified time interval, and stores all of the read data in a file. When a user accesses the web page from the web server 1, the management unit 10 loads and displays one screen of data of the web page on the display device 3 at one time. In the embodiment, one screen of data is defined as the amount of visual data the screen of the display device 3 can display at one time according to a current resolution of the display device 3. For example, if the screen of the display device 3 is currently displaying 250 words, then 250 words can represent one screen of data.
In one embodiment, the management unit 10 may include one or more function modules (as shown in
In step S10, the setting module 100 sets a time interval of how often data is retrieved from the database 40. For example, in the embodiment, the time interval is two minutes.
In step S12, when a user accesses a web page from the web server 1, the retrieving module 200 retrieves one screen of data of the web page from the database 40, and displays the one screen of data on the display device 3.
In step S14, the retrieving module 200 retrieves one screen of remaining data of the web page from the database 40 every time interval until all of the remaining data has been retrieved, and stores all of the retrieved data in a file (e.g., a XML file). The remaining data is data of the web page in the database 40 that has not been retrieved from the database 40 to the display device 3. The file is stored in the storage unit 20. In the embodiment, the retrieving module 200 may set a first tag in the database 40 to mark the retrieved data. For example, after retrieving one screen of data from the database 40, the retrieving module 200 sets a first tag T1 at the end of the one screen of data in the database 40. After retrieving a next screen of data from the database 40, the retrieving module 200 moves the first tag T1 to the end of the next screen of data in the database 40.
In step S16, the acquisition module 300 acquires a distance between a vertical scroll bar displayed on the web page (e.g., on a right side of the web page as shown in
In step S18, the determination module 400 determines whether the vertical scroll bar displayed on the web page reaches a preset position on the web page. In the embodiment, a distance between the preset position and a bottom side of the web page is H4 (H4≧0). If H1+H2=H3−H4, the determination module 400 determines that the vertical scroll bar reaches the preset position, then step S20 is implemented. If H1+H2<H3−H4 (as shown in
In step S20, the determination module 400 determines whether all of the data in the file has been loaded to the display device 3. In the embodiment, the loading module 500 may set a second tag in the file to mark the loaded data. For example, after loading one screen of data from the file to the display device 3, the loading module 500 sets a second tag T2 at the end of the one screen of data in the file. After loading a next screen of data from the file to the display device 3, the loading module 500 moves the second tag T2 to the end of the next screen of data in the file. If there is data which has not been loaded from the file to the display device 3, step S22 is implemented. If all of the data in the file has been loaded to the display device 3, the procedure ends.
In step S22, the loading module 500 loads a next screen of data of the web page from the file, and displays the next screen of data on the display device 3. Then the procedure returns to step S16.
Although certain embodiments of the present disclosure have been specifically described, the present disclosure is not to be construed as being limited thereto. Various changes or modifications may be made to the present disclosure without departing from the scope and spirit of the present disclosure.
Number | Date | Country | Kind |
---|---|---|---|
2012105596924 | Dec 2012 | CN | national |