CN105824909B - Page generation method and device - Google Patents

Page generation method and device Download PDF

Info

Publication number
CN105824909B
CN105824909B CN201610147582.5A CN201610147582A CN105824909B CN 105824909 B CN105824909 B CN 105824909B CN 201610147582 A CN201610147582 A CN 201610147582A CN 105824909 B CN105824909 B CN 105824909B
Authority
CN
China
Prior art keywords
static resource
page
cached
hash value
static
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Active
Application number
CN201610147582.5A
Other languages
Chinese (zh)
Other versions
CN105824909A (en
Inventor
张炎辉
林俊海
邱彬
林孟光
吕远方
曾健
管琰平
饶凌河
李自胜
张元超
刘庆媛
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Tencent Technology Shenzhen Co Ltd
Original Assignee
Tencent Technology Shenzhen Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Tencent Technology Shenzhen Co Ltd filed Critical Tencent Technology Shenzhen Co Ltd
Priority to CN201610147582.5A priority Critical patent/CN105824909B/en
Publication of CN105824909A publication Critical patent/CN105824909A/en
Application granted granted Critical
Publication of CN105824909B publication Critical patent/CN105824909B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/958Organisation or management of web site content, e.g. publishing, maintaining pages or automatic linking
    • G06F16/972Access to data in other repository systems, e.g. legacy data or dynamic Web page generation

Abstract

The invention relates to a page generation method and a device, wherein the method comprises the following steps: acquiring a page access request; acquiring a page address accessed by the page access request; analyzing a file directory structure of the static resource required to be requested according to the page address; extracting static resources from a static resource packet which is downloaded and cached before the page is accessed according to the analyzed file directory structure; and generating the page according to the extracted static resources. The page generation method and the page generation device provided by the invention improve the efficiency of page access.

Description

Page generation method and device
Technical Field
The invention relates to the technical field of internet, in particular to a page generation method and device.
Background
At present, a browser or an application having a browser kernel has a cache mechanism, and after a certain webpage is browsed, webpage content acquired from a webpage server can be cached, so that the cached webpage content is directly read for access when the same webpage is accessed next time, and the access efficiency is improved.
However, the current method for accelerating the access process by using the web page caching mechanism is only suitable for the situation that the web page is accessed again after the web page is accessed, if the web page is accessed for the first time, all the web page contents still need to be downloaded from the web page server, a long waiting time exists, a long-time white screen is presented to a user in the waiting time, and the access efficiency is low.
Disclosure of Invention
Therefore, it is necessary to provide a page generation method and apparatus for solving the problem of low access efficiency in the current acceleration of access process by using a web page caching mechanism.
A method of page generation, the method comprising:
acquiring a page access request;
acquiring a page address accessed by the page access request;
analyzing a file directory structure of the static resource required to be requested according to the page address;
extracting static resources from a static resource packet which is downloaded and cached before the page is accessed according to the analyzed file directory structure;
and generating the page according to the extracted static resources.
An apparatus for page generation, the apparatus comprising:
the page address acquisition module is used for acquiring a page access request; acquiring a page address accessed by the page access request;
the cache static resource analysis module is used for analyzing a file directory structure of the static resource required to be requested according to the page address;
the static resource extraction module is used for extracting static resources from a static resource packet which is downloaded and cached before the page is accessed according to the analyzed file directory structure;
and the page generating module is used for generating the page according to the extracted static resources.
According to the page generation method and the page generation device, the corresponding static resource packet is downloaded and cached when the page is not accessed, so that when the page is accessed for the first time or after the first time, the file directory structure of the static resource needing to be requested can be analyzed through the page address requesting to be accessed, the static resource needing to be requested can be extracted from the cache according to the analyzed file directory structure, the page is generated, and the access efficiency is improved. And the page address and the cached static resource packet are subjected to standard and accurate mapping through a file directory structure, the static resource in the cache can be accurately positioned through the page address, the cached static resource can be accessed efficiently, and the access efficiency is further improved.
Drawings
FIG. 1 is a diagram of an application environment of a page cache management system in one embodiment;
fig. 2 is a schematic diagram of the internal structure of the terminal in one embodiment;
FIG. 3 is a flowchart illustrating a method for generating a page in one embodiment;
FIG. 4 is a diagram illustrating a data structure of static resources in a static resource package, according to an embodiment;
FIG. 5 is a diagram illustrating an embodiment of a process for resolving static resources from a cache and rendering a page according to a page address;
FIG. 6 is a flowchart illustrating steps of updating a cache on a periodic basis in one embodiment;
FIG. 7 is a flowchart illustrating steps for downloading a static resource package for a page when the page is not being accessed in one embodiment;
FIG. 8 is a diagram that illustrates integration of pages of a web site by business category, according to one embodiment;
FIG. 9 is a flowchart illustrating steps of checking cached static resource packets and processing according to a checking result in one embodiment;
FIG. 10 is a flowchart illustrating a page generation method according to an embodiment;
fig. 11 is a schematic diagram illustrating a process of generating data required for verification when a static resource packet is issued on a server and verifying the static resource packet by using the data required for verification when the static resource packet is issued on a terminal according to an embodiment;
FIG. 12 is a block diagram showing the construction of a page generation apparatus according to an embodiment;
FIG. 13 is a block diagram showing the construction of a page generating apparatus in another embodiment;
FIG. 14 is a block diagram showing the construction of a page generating apparatus in a further embodiment;
FIG. 15 is a block diagram showing the construction of a page generation apparatus according to an embodiment;
FIG. 16 is a block diagram showing the construction of a page generating apparatus in another embodiment;
fig. 17 is a block diagram showing the structure of a page generating apparatus in still another embodiment.
Detailed Description
In order to make the objects, technical solutions and advantages of the present invention more apparent, the present invention is described in further detail below with reference to the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.
As shown in fig. 1, in one embodiment, a page cache management system is provided, comprising a terminal 102 and a server 104. The terminals 102 include desktop computers and mobile terminals including cell phones, tablet computers, PDAs (personal digital assistants), and network-enabled e-readers, among others. The server 104 includes one or more physical servers. The terminal 102 and the server 104 are connected via a network. The server 104 is used for issuing and distributing the static resource package.
As shown in fig. 2, in one embodiment, a terminal 102 is provided that includes a processor, a non-volatile storage medium, an internal memory, a network interface, a display screen, and an input device connected by a system bus. Wherein the processor has a computing function and a function of controlling the operation of the terminal 102, the processor being configured to perform a page generating method. Non-volatile storage media include magnetic storage media, optical storage media, and flash memory storage media. The nonvolatile storage medium stores an operating system and a page generating apparatus having a functional module that implements a page generating method. The internal memory is used to provide a cache for the operating system and the page generation means. The display may be a liquid crystal display or an electronic ink display. The input device comprises a touch pad, a track ball, a mouse and a touch layer overlapped with the display screen, wherein the display screen and the touch layer form the touch screen. The network interface is used for connecting to a network.
As shown in fig. 3, in an embodiment, a page generation method is provided, and this embodiment is illustrated by applying the method to the terminal 102 in fig. 1 and fig. 2. The method specifically comprises the following steps:
step 302, a page access request is obtained.
Specifically, the terminal may detect a page access trigger operation, thereby triggering a page access request, and the terminal acquires a page address requested to be accessed by the page access request. For example, the terminal may trigger a page access request to a page specified by the application management application upon detecting that the application management application is opened. The terminal can also trigger a page access request for a corresponding page when detecting the operation of clicking a link or turning to a specific page by a user.
And step 304, acquiring the page address accessed by the page access request. Wherein the page address may be represented by a URL (uniform resource Locator).
Step 306, resolving the file directory structure of the static resource required to be requested according to the page address.
Specifically, the page address points to a file of the page requested to be accessed on the server, and the page address comprises a host address and a file name to be requested, and can also comprise a subfolder name under the host address. The directories at all levels in the page address are separated by the directory separator, so that the file directory structure of the static resource to be requested can be analyzed from the page address by using the directory separator.
Step 308, extracting static resources from the static resource package that has been downloaded and cached before the page was accessed according to the parsed file directory structure.
Specifically, the cached static resource package is organized according to a file directory, and at this time, a file directory structure is resolved according to the web page address, so that a mapping relationship between the web page address and the cached static resource package can be obtained, and the requested static resource can be extracted from the cached static resource package according to the mapping relationship.
The page refers to a page which can be accessed through a network, such as a webpage or a page which is embedded into a local interface and acquires page data through the network; the page is not accessed, which means that the page is not accessed by the terminal. Static resources refer to data that can be directly obtained from a server in the form of a file, used to generate a page, and are generally the same for different users. Static resources such as pictures in a page, style data (e.g. CSS, cascading style sheet), script files, or HTML (Hypertext Markup Language) files. Correspondingly, a dynamic resource is a changing resource, which is generally different for different users, such as a database data.
The static resource package is a collection of static resources, and the static resource package can adopt a zip or rar or other compression package format. Static resources in the static resource package are organized according to a file directory, a main folder can be established in the static resource package according to a host address, files are stored in the main folder or subfolders are established in the main folder, and the file directory is formed by the folder attribution relation among all the files in the main folder. Referring to fig. 4, a main folder test.yyb.com is established in a static resource package by a host address test.yyb.com, a navigation page file index.html is stored under the main folder, a plurality of subfolders with names "cs", "img" or "js" are established under the main folder according to resource categories, and static resources of corresponding resource categories are stored under the subfolders.
In one embodiment, the terminal may download a static resource package of the page when the page is not accessed, and the static resources in the static resource package are organized by a file directory. Specifically, the terminal may specify a page, thereby downloading a static resource package of the specified page from the server. For example, the terminal may be run with an application management application (such as an application store) having a page designated for access, or the user may set the designated page autonomously. The terminal can also actively inquire the pages with the downloadable static resource packages from the server so as to download the static resource packages of the corresponding pages. The server can also actively push the static resource package and download by the terminal. The terminal can directly cache the downloaded static resource packet in the cache, or can decompress the downloaded static resource packet and cache the decompressed static resource packet in the cache and reserve the file directory structure of each static resource in the static resource packet.
And 310, generating a page according to the extracted static resources.
Specifically, if the page does not include dynamic resources, the terminal can directly render the page according to the extracted static resources; if the page comprises the dynamic resources, the terminal can pull the dynamic resources from the server where the page is located, and render the page according to the static resources and the dynamic resources.
For example, referring to fig. 5, after obtaining http:// www.xx.com/visit/index. html of a page address, the terminal inputs the page address to a cache resolver packaged by the page generating method, the cache resolver resolves a file directory structure according to the page address and extracts corresponding static resources from a cache according to the file directory structure, outputs the extracted static resources according to the file directory structure, and renders a control of the page according to the output static resources.
According to the page generation method, when the page is not accessed, the corresponding static resource package is downloaded and cached, and the static resources in the static resource package are organized according to the file directory, so that when the page is accessed for the first time or after the first time, the file directory structure of the static resources needing to be requested can be analyzed through the page address requesting to be accessed, the static resources needing to be requested can be extracted from the cache according to the analyzed file directory structure, the page is generated, and the access efficiency is improved. And the page address and the cached static resource packet are subjected to standard and accurate mapping through a file directory structure, the static resource in the cache can be accurately positioned through the page address, the cached static resource can be accessed efficiently, and the access efficiency is further improved.
In an embodiment, the method further includes a step of updating the cache periodically, and specifically includes the following steps with reference to fig. 6:
step 602, periodically check for updated static resources compared to the cached static resource packages.
Specifically, the terminal may compare the cached static resource packet with the latest static resource packet of the page on the server according to a preset period, for example, every day or every 1 hour, and if the static resource packet is not consistent, it indicates that a static resource packet updated compared with the cached static resource packet exists on the server, and if the static resource packet is consistent, it indicates that a static resource updated compared with the cached static resource packet does not exist on the server. When the terminal compares the cached static resource packet with the latest static resource packet of the page on the server, the hash value of the cached static resource packet and the latest static resource packet can be compared.
Step 604, the updated static resources are downloaded.
Specifically, the terminal may download only the static resource updated compared to the cached static resource package, or download the latest static resource package with the complete page.
And step 606, updating the cached static resource package according to the downloaded updated static resource.
Specifically, the terminal adds the downloaded static resource to the file directory structure of the cached static resource package according to the file directory structure of the downloaded static resource in the latest static resource package, so as to update the cached static resource package in the cache.
In this embodiment, the terminal periodically checks the static resource updated by the static resource packet compared to the cache and updates the cached static resource packet, so that the cached static resource packet can be ensured to be in the latest state, and the situation that the latest page cannot be accessed because the cache is not updated in time is avoided.
As shown in fig. 7, in an embodiment, the method further includes a step of downloading a static resource package of the page when the page is not accessed, and specifically includes the following steps:
step 702, obtain an online page access request.
In particular, an online page access request refers to an access request to an online page on a server, the online page being uncached.
Step 704, obtaining the business category of the online page requested by the online page access request.
Step 706, download and cache the static resource packages of all pages belonging to the traffic class.
Specifically, each page of the website is organized according to business categories, and each business category corresponds to a plurality of pages. Referring to fig. 8, service 1 is a set of offer-related pages, corresponding offer pages and offer detail pages 1 to N, etc.; service N is another service and corresponds to multiple pages. After any page in the service class is accessed, the terminal downloads and caches the static resource packages of all pages of the service class.
The terminal can actively download the static resource packages of all the pages belonging to the business category after acquiring the business category to which the online page requested by the online page access request belongs. The server may also push the static resource packages of all the pages belonging to the service category to the terminal after acquiring the service category to which the online page requested by the online page access request belongs, and download the static resource packages by the server. The terminal may specifically download the static resource packages of all pages belonging to the service class when the network is idle.
In this embodiment, the static resources in the static resource package are organized according to the service class, and when the terminal accesses a page of a certain service class, the terminal is triggered to download the static resource package of the service class. Because the static resource package needs to be downloaded before the user accesses the page, the data volume of the static resource package to be downloaded is undoubtedly huge, and when a certain page in the business class is accessed, it indicates that the user has a potential need of accessing other pages in the business class, and at this time, the static resource packages of all the pages in the business class are triggered to be downloaded, so that the user can efficiently access other pages in the business class.
In one embodiment, after step 304, the method further comprises: judging whether an offline access condition is met; if yes, go to step 306; and if not, sending a page access request for requesting to access the page, and receiving page data fed back according to the page access request.
The offline access condition refers to a condition that a page should be accessed through a cache. If the offline access condition is met, performing offline access, and executing steps 306 to 310; and if the offline access condition is not met, acquiring a page access request for accessing the page, sending the page access request to the server, and receiving page data fed back by the server according to the page access request. The page data that is fed back may include static resources and/or dynamic resources.
In one embodiment, the offline access condition includes at least one of the following conditions: (1) and the first time length from the last time of accessing the page to the current time of accessing the page is less than the first preset time length. (2) And the second time length from the last time of caching the static resource packet to the current time is less than the second preset time length. (3) And checking the cached static resource packet, wherein the checking result indicates that the cached static resource packet is not tampered.
If the survival time exceeds the first preset time or the second preset time, the survival time of the cached static resource packet is too long, and the static resource packet is probably not the latest static resource packet, at this moment, online access can be performed, and page data fed back by the server is cached. If the survival time is less than or equal to the first preset time length or the second preset time length, it can be said that the cached static resource packet is still newer, and at this time, offline access can be performed.
And checking the cached static resource packet to check whether the cached static resource is maliciously tampered, such as maliciously tampered by a malicious program or a malicious user. If the static resource package is tampered with, the cached static resource package cannot be used, online access is needed, and the latest static resource package of the page can be downloaded again.
In this embodiment, whether the offline access condition is satisfied is determined, so that offline access is performed by using the cached static resource packet when offline access is available, and online access is performed when offline access is unavailable, so that the cached static resource packet can be correctly used at a proper time.
In one embodiment, the static resource packet that is downloaded and cached carries a hash value generated from the static resource in the static resource packet. Step 304 is followed by a step of verifying the cached static resource packet and processing according to a verification result, which specifically includes: calculating the hash value of the static resource in the cached static resource packet; judging whether the calculated hash value is consistent with the hash value carried by the cached static resource packet; if yes, go to step 306. And if not, sending a page access request for requesting to access the page, and receiving page data fed back according to the page access request.
The hash value is a value obtained by mapping data from a domain to a value range smaller than the domain by using a hash function, such as an MD5(Message Digest Algorithm MD5, fifth version of Message Digest Algorithm) value or an SHA (secure hash Algorithm) value.
When the static resource packet is released on the server, the server can calculate the hash value of each resource in the static resource packet, and when the terminal downloads the static resource packet, the server carries the calculated hash value in the static resource packet and sends the static resource packet to the terminal. And the terminal caches the static resources and the corresponding hash values in the static resource packet when downloading the static resource packet. The terminal calculates the hash value of each static resource in the cached static resource packet, compares the hash value with the hash value carried by the cached static resource packet, and if the hash value is consistent to indicate that the cached static resource packet is not tampered, the terminal can execute steps 306 to 310 to perform offline access. If the inconsistency indicates that the cached static resource packages are not credible due to tampering or cache errors and the like, online access can be performed.
In this embodiment, the downloaded and cached static resource packet carries the hash value, so that whether the cached static resource packet is tampered or not can be judged according to the hash value when offline access is required, and thus, the security of page access can be improved.
In one embodiment, the downloaded and cached static resource packet carries a hash value and signature data generated according to the static resources in the static resource packet, and the signature data is generated by encrypting the hash value of each static resource in the static resource packet according to a private key. After step 304, the method further includes the steps of verifying the cached static resource packet and processing according to a verification result, and with reference to fig. 9, the method specifically includes:
step 902, decrypting the hash value from the signature data according to the public key corresponding to the private key.
Specifically, after the static resource packet is issued on the server, the server calculates respective hash values of each static resource in the static resource packet, encrypts the calculated hash values according to a private key to obtain signature data, and issues the static resource packet carrying the hash values and the signature data when issuing the static resource packet. And the terminal downloads and caches the static resource packet which is sent by the server and carries the hash value and the signature data.
When the terminal accesses the page, validity verification is performed on the signature data, for example, whether the signature data is in a valid period or not, whether the signature data format is correct or not is verified, and validity verification can be performed on the signature data according to the public key, and whether normal decryption can be performed according to the public key or not is also verified. And if the signature data is valid, decrypting the hash value from the signature data according to the public key. Wherein the private key and the public key form a key pair.
And step 904, checking whether the hash value carried by the static resource packet is valid according to the decrypted hash value. If so, go to step 906; if not, go to step 910.
Specifically, the terminal may compare the decrypted hash value with the hash value carried by the static resource packet, and if the hash value is consistent with the hash value carried by the static resource packet, the carried hash value is valid; if not, the carried hash value is invalid.
Step 906, calculating the hash value of the static resource in the cached static resource packet.
Specifically, the terminal calculates the hash value of each static resource in the cached static resource packet by using the same hash function as that used by the server to calculate the hash value. The terminal can also only calculate the hash value of the static resource to be extracted in the static resource packet.
Step 908, determine whether the calculated hash value is consistent with the hash value carried by the cached static resource packet. If yes, go to step 306; if not, step 910 can be performed.
Specifically, the terminal compares the calculated hash value with the decrypted hash value, and if the calculated hash value is consistent with the decrypted hash value, the cached static resource packet is not tampered, and the offline access can be continuously performed by using the cache. The terminal may determine whether the calculated hash value matches the decrypted hash value. Step 902 may also be performed after step 306, and step 308 may be performed when a match is determined in step 908; step 902 may also be performed after step 308 and step 310 performed when a match is determined in step 908.
Step 910, sending a page access request requesting to access a page, and receiving page data fed back according to the page access request.
Specifically, the terminal sends a page access request for requesting to access a page to the server, the server feeds page data requested by the page access request back to the terminal according to the page access request, and the terminal receives the page data and generates a page requested by the page access request according to the page data.
In this embodiment, the hash value of the static resource in the static resource table is encrypted by the asymmetric encryption algorithm to generate signature data, and the hash value and the signature data are carried in the static resource packet. The application program on the terminal can decrypt the hash value from the signature data when the application program has the public key matched with the private key on the server, so that the decrypted hash value is used for checking the hash value carried by the cached static resource packet, and then the hash value is used for checking whether the cached static resource packet is tampered, and the safety is further improved.
For example, referring to fig. 10, a service party issues a static resource package on a server according to a service category to which a page belongs, and a terminal queries and downloads the static resource package from the server, caches the downloaded static resource package, and periodically updates the cached static resource package. When accessing the page, judging whether an offline access condition is met, if so, accessing the cache, extracting the requested static resource from the cache and generating a corresponding page; and if not, directly accessing the page on the website.
Referring to fig. 11, after receiving a publishing application from a service party, a server calculates MD5 values of all static resources in a static resource packet to be published, and composes structured data verify.json from all the calculated MD5 values according to a certain format, encrypts the structured data by using a private key to obtain signature data verify.signature, and carries both the structured data verify.json and the signature data verify.signature into a corresponding static resource packet. The server issues a static resource packet to the terminal, the terminal downloads the static resource packet, obtains structured data verify and signature from the static resource packet when offline access is needed, decrypts the structured data verify and signature from the signature data verify and signature by using a public key, and checks whether the structured data verify and signature are valid. And if the static resource package is valid, checking the MD5 value in the structured data verify, and if the check is passed, extracting the static resource to be requested from the cached static resource package and generating the page.
As shown in fig. 12, in one embodiment, there is provided a page generating apparatus 1200, including: a page address obtaining module 1203, a cache static resource analyzing module 1204, a static resource extracting module 1205, and a page generating module 1206.
A page address obtaining module 1203, configured to obtain a page access request; and acquiring the page address accessed by the page access request.
Specifically, the page address obtaining module 1203 may detect a page access triggering operation, so as to trigger access to the page, and the page address obtaining module 1203 obtains a page address requested to be accessed by the page access triggering operation. For example, page address acquisition module 1203 may trigger access to a page specified by the application management application upon detecting that the application management application is opened. The page address obtaining module 1203 may also trigger access to a corresponding page when detecting an operation of clicking a link or turning to a specific page by the user. The page address may be represented by a URL.
And the cache static resource analyzing module 1204 is configured to analyze a file directory structure of the static resource that needs to be requested according to the page address.
Specifically, the page address points to a file of the page requested to be accessed on the server, and the page address comprises a host address and a file name to be requested, and can also comprise a subfolder name under the host address. The directories at all levels in the page address are separated by the directory separator, so that the file directory structure of the static resource to be requested can be analyzed from the page address by using the directory separator.
And the static resource extraction module 1205 is configured to extract the static resource from the static resource package that has been downloaded and cached before the page is accessed according to the parsed file directory structure.
Specifically, the cached static resource package is organized according to a file directory, and at this time, the static resource extraction module 1205 resolves the file directory structure according to the web page address, so as to obtain a mapping relationship between the web page address and the cached static resource package, and thus, according to the mapping relationship, the requested static resource can be extracted from the cached static resource package.
The page refers to a page which can be accessed through a network, such as a webpage or a page which is embedded into a local interface and acquires page data through the network; the page is not accessed, which means that the page is not accessed by the terminal. Static resources refer to data that can be directly obtained from a server in the form of a file, used to generate a page, and are generally the same for different users. Static resources such as pictures in a page, style data (e.g. CSS, cascading style sheet), script files, or HTML (Hypertext Markup Language) files. Correspondingly, a dynamic resource is a changing resource, which is generally different for different users, such as a database data.
The static resource package is a collection of static resources, and the static resource package can adopt a zip or rar or other compression package format. Static resources in the static resource package are organized according to a file directory, a main folder can be established in the static resource package according to a host address, files are stored in the main folder or subfolders are established in the main folder, and the file directory is formed by the folder attribution relation among all the files in the main folder. Referring to fig. 4, a main folder test.yyb.com is established in a static resource package by a host address test.yyb.com, a navigation page file index.html is stored under the main folder, a plurality of subfolders with names "cs", "img" or "js" are established under the main folder according to resource categories, and static resources of corresponding resource categories are stored under the subfolders.
As shown in fig. 13, in one embodiment, the page generating apparatus 1200 further includes a downloading module 1201 and a caching module 1202.
The downloading module 1201 is configured to download a static resource package of a page when the page is not accessed, where static resources in the static resource package are organized according to a file directory.
Specifically, the download module 1201 may specify a page, thereby downloading a static resource package of the specified page from a server. The downloading module 1201 may actively query a server for a page having a downloadable static resource package, thereby downloading the static resource package of the corresponding page. The server may also actively push the static resource package and download it by the download module 1201.
And the caching module 1202 is configured to cache the downloaded static resource package.
And the page generating module 1206 is configured to generate a page according to the extracted static resource.
Specifically, if the page does not include dynamic resources, the page generating module 1206 may directly render the page according to the extracted static resources; if the page includes dynamic resources, the page generation module 1206 may pull the dynamic resources from the server where the page is located, and render the page according to the static resources and the dynamic resources.
The page generating device 1200 downloads and caches the corresponding static resource package when the page is not accessed, and the static resources in the static resource package are organized according to the file directory, so that when the page is accessed for the first time or after the first time, the file directory structure of the static resources required to be requested can be analyzed through the page address requested to be accessed, the static resources required to be accessed can be extracted from the cache according to the analyzed file directory structure, and the page is generated, and the access efficiency is improved. And the page address and the cached static resource packet are subjected to standard and accurate mapping through a file directory structure, the static resource in the cache can be accurately positioned through the page address, the cached static resource can be accessed efficiently, and the access efficiency is further improved.
As shown in fig. 14, in one embodiment, the page generating apparatus 1200 further includes: the checking module 1207 is configured to check the static resource updated by the static resource package compared to the cache periodically.
Specifically, the checking module 1207 may compare the cached static resource packet with the latest static resource packet of the page on the server according to a preset period, for example, every day or every 1 hour, and if the static resource packet is inconsistent with the latest static resource packet of the page on the server, it indicates that a static resource packet updated compared with the cached static resource packet exists on the server, and if the static resource packet is consistent with the latest static resource packet, it indicates that a static resource updated compared with the cached static resource packet does not exist on the server. When checking module 1207 compares the cached static resource packet with the latest static resource packet of the page on the server, the hash values of the cached static resource packet and the latest static resource packet may be compared.
The downloading module 1201 is also used for downloading the updated static resource.
Specifically, the downloading module 1201 may only download the static resource updated compared to the cached static resource package, or download the latest static resource package with the complete page.
The caching module 1202 is further configured to update the cached static resource package according to the downloaded updated static resource.
Specifically, the caching module 1202 adds the downloaded static resource to the file directory structure of the cached static resource package according to the file directory structure of the downloaded static resource in the latest static resource package, so as to update the cached static resource package in the cache.
In this embodiment, the static resource updated by the static resource packet compared to the cache is periodically checked and the cached static resource packet is updated, so that the cached static resource packet can be ensured to be in the latest state, and the situation that the latest page cannot be accessed because the cache is not updated in time is avoided.
In one embodiment, the downloading module 1201 is further configured to obtain an online page access request; acquiring the business category of an online page requested by an online page access request; the static resource packages of all pages belonging to the traffic class are downloaded.
The caching module 1202 is further configured to cache the downloaded static resource package.
Specifically, each page of the website is organized according to business categories, and each business category corresponds to a plurality of pages. Referring to fig. 8, service 1 is a set of offer-related pages, corresponding offer pages and offer detail pages 1 to N, etc.; service N is another service and corresponds to multiple pages. After any page in the service class is accessed, the terminal downloads the static resource packages of all pages of the service class.
The terminal can actively download the static resource packages of all the pages belonging to the business category after acquiring the business category to which the online page requested by the online page access request belongs. The server may also push the static resource packages of all the pages belonging to the service category to the terminal after acquiring the service category to which the online page requested by the online page access request belongs, and download the static resource packages by the server. The terminal may specifically download the static resource packages of all pages belonging to the service class when the network is idle.
In this embodiment, the static resources in the static resource package are organized according to the service class, and when the terminal accesses a page of a certain service class, the terminal is triggered to download the static resource package of the service class. Because the static resource package needs to be downloaded before the user accesses the page, the data volume of the static resource package to be downloaded is undoubtedly huge, and when a certain page in the business class is accessed, it indicates that the user has a potential need of accessing other pages in the business class, and at this time, the static resource packages of all the pages in the business class are triggered to be downloaded, so that the user can efficiently access other pages in the business class.
As shown in fig. 15, in one embodiment, the page generating apparatus 1200 further includes: a first determination module 1208 and a page request module 1209.
The first determining module 1208 is configured to determine whether the offline access condition is satisfied. The offline access condition refers to a condition that a page should be accessed through a cache.
The page request module 1209 is configured to send a page access request requesting to access a page if the offline access condition is not satisfied, and receive page data fed back according to the page access request.
The cache static resource parsing module 1204 is further configured to parse a file directory structure of the static resource that needs to be requested according to the page address if the offline access condition is met.
In this embodiment, whether the offline access condition is satisfied is determined, so that offline access is performed by using the cached static resource packet when offline access is available, and online access is performed when offline access is unavailable, so that the cached static resource packet can be correctly used at a proper time.
In one embodiment, the offline access condition includes at least one of the following conditions: (1) and the first time length from the last time of accessing the page to the current time of accessing the page is less than the first preset time length. (2) And the second time length from the last time of caching the static resource packet to the current time is less than the second preset time length. (3) And checking the cached static resource packet, wherein the checking result indicates that the cached static resource packet is not tampered.
In one embodiment, the static resource packet that is downloaded and cached carries a hash value generated from the static resource in the static resource packet. As shown in fig. 16, the page generating apparatus 1200 further includes a hash value calculation module 1210 and a second judgment module 1211.
And a hash value calculation module 1210 configured to calculate a hash value of the static resource in the cached static resource packet.
The hash value is a value obtained by mapping data from a domain to a value range smaller than the domain by using a hash function, such as an MD5(Message Digest Algorithm MD5, fifth version of Message Digest Algorithm) value or an SHA (secure hash Algorithm) value.
When the static resource packet is released on the server, the server can calculate the hash value of each resource in the static resource packet, and when the terminal downloads the static resource packet, the server carries the calculated hash value in the static resource packet and sends the static resource packet to the terminal. After the downloading module 1201 downloads the static resource package, the caching module 1202 caches the static resource and the corresponding hash value in the static resource package. The hash value calculation module 1210 calculates a hash value of each static resource in the cached static resource packet.
A second determining module 1211, configured to determine whether the calculated hash value is consistent with the hash value carried by the cached static resource packet.
Specifically, the second determining module 1211 compares the calculated hash value with the hash value carried by the cached static resource packet, so as to determine whether the cached static resource packet is tampered.
The cache static resource parsing module 1204 is further configured to parse a file directory structure of the static resource to be requested according to the page address if the determination result of the second determination module 1211 is consistent.
Specifically, if the second determination module 1211 determines that the static resource packet is consistent, which indicates that the cached static resource packet is not tampered, offline access may be performed. If the second determination module 1211 determines that the inconsistency indicates that the cached static resource package is not trusted due to tampering or a cache error, the online access may be performed.
In this embodiment, the downloaded and cached static resource packet carries the hash value, so that whether the cached static resource packet is tampered or not can be judged according to the hash value when offline access is required, and thus, the security of page access can be improved.
In one embodiment, the downloaded and cached static resource packet further carries signature data, and the signature data is generated by encrypting the hash value of each static resource in the static resource packet according to a private key. After the static resource packet is issued on the server, the server calculates the respective hash value of each static resource in the static resource packet, encrypts the calculated hash value according to the private key to obtain signature data, and issues the static resource packet carrying the hash value and the signature data when issuing the static resource packet. And the terminal downloads and caches the static resource packet which is sent by the server and carries the hash value and the signature data.
As shown in fig. 17, the page generating apparatus 1200 further includes a validity verifying module 1212, configured to decrypt a hash value from the signature data according to a public key corresponding to the private key; and checking whether the hash value carried by the static resource packet is valid or not according to the decrypted hash value.
The validity verification module 1212 may be further configured to perform validity verification on the signature data when the page is accessed, for example, to verify whether the signature data is in a validity period, whether a format of the signature data is correct, and the like, and may also perform validity verification on the signature data according to the public key, for example, whether the signature data can be decrypted normally according to the public key. And if the signature data is valid, decrypting the hash value from the signature data according to the public key. Wherein the private key and the public key form a key pair.
The hash value calculation module 1210 is further configured to calculate a hash value of the static resource in the cached static resource packet if the verification result of the validity verification module is valid.
In one embodiment, after the static resource package is released on the server, the server calculates the respective hash value of each static resource in the static resource package, encrypts the calculated hash value according to a private key to obtain signature data, and issues the static resource package carrying the signature data when issuing the static resource package.
In this embodiment, the hash value of the static resource in the static resource table is encrypted by the asymmetric encryption algorithm to generate signature data, and the hash value and the signature data are carried in the static resource packet. The application program on the terminal can decrypt the hash value from the signature data when the application program has the public key matched with the private key on the server, so that the decrypted hash value is used for checking the hash value carried by the cached static resource packet, and then the hash value is used for checking whether the cached static resource packet is tampered, and the safety is further improved.
It will be understood by those skilled in the art that all or part of the processes of the methods of the embodiments described above can be implemented by a computer program, which can be stored in a computer-readable storage medium, and when executed, can include the processes of the embodiments of the methods described above. The storage medium may be a non-volatile storage medium such as a magnetic disk, an optical disk, a Read-Only Memory (ROM), or a Random Access Memory (RAM).
The technical features of the above embodiments can be arbitrarily combined, and for the sake of brevity, all possible combinations of the technical features in the above embodiments are not described, but should be considered as the scope of the present specification as long as there is no contradiction between the combinations of the technical features.
The above examples only show some embodiments of the present invention, and the description thereof is more specific and detailed, but not construed as limiting the scope of the invention. It should be noted that, for a person skilled in the art, several variations and modifications can be made without departing from the inventive concept, which falls within the scope of the present invention. Therefore, the protection scope of the present patent shall be subject to the appended claims.

Claims (16)

1. A page generation method is applied to a terminal, and comprises the following steps:
acquiring an access request for accessing an online page on a server;
acquiring the service category of the online page requested by the access request;
downloading and caching the static resource packages of all the pages belonging to the service category, and mapping the page addresses of all the pages and the cached static resource packages through a file directory structure;
detecting a page access triggering operation aiming at the page access belonging to the same service class as the online page, and triggering a page access request;
acquiring a page address accessed by the page access request, wherein directories at all levels in the page address are separated by a directory delimiter;
when the page accessed by the page access request meets an offline access condition, analyzing a file directory structure of static resources to be requested from the page address according to the directory delimiter;
extracting static resources from a static resource packet which is downloaded and cached before the page is accessed according to the analyzed file directory structure;
generating the page according to the extracted static resources;
wherein the offline access condition comprises:
and the first time length from the last time of accessing the page to the current time of accessing the page is less than a first preset time length.
2. The method of claim 1, further comprising:
periodically checking the updated static resources compared to the cached static resource packages;
downloading the updated static resource;
and updating the cached static resource packet according to the downloaded updated static resource.
3. The method of claim 1, wherein after obtaining the page address accessed by the page access request, the method comprises:
judging whether an offline access condition is met;
and if not, sending a page access request for requesting to access the page, and receiving page data fed back according to the page access request.
4. The method of claim 3, wherein the offline access condition further comprises at least one of:
a second time length from the last time of caching the static resource packet to the current time is less than a second preset time length;
and checking the cached static resource packet, wherein the checking result indicates that the cached static resource packet is not tampered.
5. The method of claim 1, wherein the static resource package downloaded and cached carries hash values generated from static resources in the static resource package; when the page is accessed, after the page address requested to be accessed is obtained, the method includes:
calculating the hash value of the static resource in the cached static resource packet;
judging whether the calculated hash value is consistent with the hash value carried by the cached static resource packet;
and if the static resource is consistent with the page address, analyzing the file directory structure of the static resource needing to be requested according to the page address.
6. When the method is used according to claim 5, the downloaded and cached static resource packet further carries signature data, and the signature data is generated by encrypting the hash value of each static resource in the static resource packet according to a private key; after the obtaining of the page address accessed by the page access request, the method further includes:
decrypting a hash value from the signature data according to a public key corresponding to the private key;
verifying whether the hash value carried by the static resource packet is valid or not according to the decrypted hash value;
and if the static resource packet is valid, executing the step of calculating the hash value of the static resource in the cached static resource packet.
7. The method as claimed in claim 6, wherein after the static resource package is released on a server, the server calculates a hash value of each static resource in the static resource package, encrypts the calculated hash value according to the private key to obtain signature data, and releases the static resource package carrying the signature data when the static resource package is released.
8. An apparatus for generating a page, the apparatus comprising:
the downloading module is used for acquiring an access request for accessing an online page on the server; acquiring the service category of the online page requested by the access request; downloading and caching the static resource packages of all the pages belonging to the service category, and mapping the page addresses of all the pages and the cached static resource packages through a file directory structure;
the page address acquisition module is used for detecting that a page access request is triggered when page access triggering operation which belongs to the same service class as the online page is performed; acquiring a page address accessed by the page access request, wherein directories at all levels in the page address are separated by a directory delimiter;
the cache static resource analysis module is used for analyzing a file directory structure of the static resource to be requested from the page address according to the directory delimiter when the page accessed by the page access request meets an offline access condition;
the static resource extraction module is used for extracting static resources from a static resource packet which is downloaded and cached before the page is accessed according to the analyzed file directory structure; the page generation module is used for generating the page according to the extracted static resources;
wherein the offline access condition comprises:
and the first time length from the last time of accessing the page to the current time of accessing the page is less than a first preset time length.
9. The apparatus of claim 8, further comprising:
the checking module is used for checking the static resources updated by the static resource packet compared with the cache periodically;
the downloading module is used for downloading the updated static resource;
and the cache module is used for updating the cached static resource packet according to the downloaded updated static resource.
10. The apparatus of claim 8, further comprising:
the first judgment module is used for judging whether an offline access condition is met;
and the page request module is used for sending a page access request for requesting to access the page and receiving page data fed back according to the page access request if the offline access condition is not met.
11. The apparatus of claim 10, wherein the offline access condition further comprises at least one of:
a second time length from the last time of caching the static resource packet to the current time is less than a second preset time length;
and checking the cached static resource packet, wherein the checking result indicates that the cached static resource packet is not tampered.
12. The apparatus of claim 8, wherein the static resource package downloaded and cached carries a hash value generated from the static resources in the static resource package; the device further comprises:
the hash value calculation module is used for calculating the hash value of the static resource in the cached static resource packet;
the second judgment module is used for judging whether the calculated hash value is consistent with the hash value carried by the cached static resource packet;
and the cache static resource analysis module is further used for analyzing the file directory structure of the static resource to be requested according to the page address if the judgment result of the second judgment module is consistent.
13. The apparatus according to claim 12, wherein the downloaded and cached static resource package further carries signature data, and the signature data is generated by encrypting hash values of each static resource in the static resource package according to a private key; the device further comprises:
the validity verification module is used for decrypting a hash value from the signature data according to a public key corresponding to the private key; verifying whether the hash value carried by the static resource packet is valid or not according to the decrypted hash value;
and the hash value calculation module is also used for calculating the hash value of the static resource in the cached static resource packet if the verification result of the validity verification module is valid.
14. The apparatus according to claim 13, wherein after the static resource package is issued on a server, the server calculates a hash value of each static resource in the static resource package, encrypts the calculated hash value according to the private key to obtain signature data, and issues the static resource package carrying the signature data when issuing the static resource package.
15. A computer-readable storage medium, on which a computer program is stored, which, when being executed by a processor, carries out the steps of the method of any one of claims 1 to 7.
16. A terminal comprising a memory and a processor, the memory storing a computer program that, when executed by the processor, causes the processor to perform the steps of the method according to any one of claims 1 to 7.
CN201610147582.5A 2016-03-15 2016-03-15 Page generation method and device Active CN105824909B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201610147582.5A CN105824909B (en) 2016-03-15 2016-03-15 Page generation method and device

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201610147582.5A CN105824909B (en) 2016-03-15 2016-03-15 Page generation method and device

Publications (2)

Publication Number Publication Date
CN105824909A CN105824909A (en) 2016-08-03
CN105824909B true CN105824909B (en) 2020-05-29

Family

ID=56987320

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201610147582.5A Active CN105824909B (en) 2016-03-15 2016-03-15 Page generation method and device

Country Status (1)

Country Link
CN (1) CN105824909B (en)

Families Citing this family (19)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN106598567A (en) * 2016-11-03 2017-04-26 广州凯耀资产管理有限公司 Method and device for displaying page elements on terminal equipment
CN108241689A (en) * 2016-12-26 2018-07-03 广州市动景计算机科技有限公司 Page resource acquisition methods, device and client device
CN108287839B (en) * 2017-01-09 2022-01-28 阿里巴巴集团控股有限公司 Page loading method and equipment
CN108287836B (en) * 2017-01-09 2022-09-13 腾讯科技(深圳)有限公司 Resource caching method and device
CN107105336B (en) * 2017-04-19 2021-01-08 腾讯科技(深圳)有限公司 Data processing method and data processing device
CN109474563A (en) * 2017-09-08 2019-03-15 阿里巴巴集团控股有限公司 Processing, providing method, client and the server of file stream
CN108334562A (en) * 2018-01-09 2018-07-27 阿里巴巴集团控股有限公司 A kind of page display method and device
CN108347479B (en) * 2018-01-26 2020-12-18 政采云有限公司 Multi-warehouse static resource uploading method and system based on content distribution network
CN109547838B (en) * 2018-12-06 2021-06-01 青岛海信传媒网络技术有限公司 Video window processing method and device
CN109933737A (en) * 2019-03-22 2019-06-25 中国工商银行股份有限公司 Webpage processing method, apparatus and system
CN110515631B (en) * 2019-08-23 2023-06-09 掌阅科技股份有限公司 Method for generating application installation data packet, server and computer storage medium
CN113158098B (en) * 2020-01-07 2024-03-19 百度在线网络技术(北京)有限公司 Page generation method, device, equipment and medium
CN112015485A (en) * 2020-08-14 2020-12-01 北京达佳互联信息技术有限公司 Page display method and device, electronic equipment and storage medium
CN112261090B (en) * 2020-09-28 2022-06-17 成都长虹网络科技有限责任公司 Web data processing method and device, computer equipment and readable storage medium
CN112395191A (en) * 2020-11-16 2021-02-23 北京五八信息技术有限公司 Information processing method and device
CN112632440B (en) * 2020-12-18 2023-01-24 西安博达软件股份有限公司 Static resource generation method for teacher personal homepage based on watermark characteristic rule string
CN112887362B (en) * 2021-01-08 2023-03-10 重庆锐明信息技术有限公司 Equipment access method, equipment access device and server
CN113268261B (en) * 2021-07-16 2022-05-10 北京乐学帮网络技术有限公司 Page content display method and device and electronic equipment
CN116980233B (en) * 2023-09-21 2024-01-30 宝略科技(浙江)有限公司 Authorization verification method and system for discrete data during high-frequency access

Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103218434A (en) * 2013-04-15 2013-07-24 北京小米科技有限责任公司 Method and device for loading static resource
CN103617165A (en) * 2013-10-22 2014-03-05 小米科技有限责任公司 Picture loading method, device and terminal
CN103870487A (en) * 2012-12-13 2014-06-18 腾讯科技(深圳)有限公司 Webpage file processing method and mobile terminal

Family Cites Families (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102438045B (en) * 2011-12-07 2015-07-08 深圳市深信服电子科技有限公司 Method and system for pre-fetching web page, and method for accessing web page

Patent Citations (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103870487A (en) * 2012-12-13 2014-06-18 腾讯科技(深圳)有限公司 Webpage file processing method and mobile terminal
CN103218434A (en) * 2013-04-15 2013-07-24 北京小米科技有限责任公司 Method and device for loading static resource
CN103617165A (en) * 2013-10-22 2014-03-05 小米科技有限责任公司 Picture loading method, device and terminal

Also Published As

Publication number Publication date
CN105824909A (en) 2016-08-03

Similar Documents

Publication Publication Date Title
CN105824909B (en) Page generation method and device
CN109257340B (en) Website tamper-proof system and method based on block chain
KR101723937B1 (en) Cloud-assisted method and service for application security verification
US7673135B2 (en) Request authentication token
US10754634B1 (en) Customized application package with context specific token
US8997239B2 (en) Detecting code injections through cryptographic methods
US8607335B1 (en) Internet file safety information center
WO2015101561A1 (en) Method and system for providing transparent trusted computing
EP3253026B1 (en) Cdn-based access control method and relevant device
CN109376133B (en) File access method and file access system
US10474729B2 (en) Delayed encoding of resource identifiers
CN110888838B (en) Request processing method, device, equipment and storage medium based on object storage
JP2013519963A (en) Prevent unauthorized font links
US10505736B1 (en) Remote cyber security validation system
CN110708335A (en) Access authentication method and device and terminal equipment
Levy et al. Stickler: Defending against malicious content distribution networks in an unmodified browser
CN106101155B (en) Method and device for protecting website
CN113518080B (en) TLS encrypted traffic detection method and device and electronic equipment
CN112241298A (en) Page display method and device, storage medium and electronic device
CN110768974B (en) Control method for single-page application real-time view authority
CN112788084B (en) Application program installation package downloading method, application program installation package pushing device and computer equipment
EP3647979A1 (en) Device attestation techniques
CN111541758A (en) Page updating method and device
CN115640471A (en) Short link generation method and device, computer equipment and storage medium
CN113590994A (en) Data processing method, data processing device, computer equipment and storage medium

Legal Events

Date Code Title Description
C06 Publication
PB01 Publication
C10 Entry into substantive examination
SE01 Entry into force of request for substantive examination
GR01 Patent grant
GR01 Patent grant