A web page file distribution method and device

By generating the first web page file containing the target code for each web page running environment, and sending the corresponding file according to the client's web page running environment, the problem of excessive amount of web page file data is solved, and the loading speed and access speed are improved.

CN114707090BActive Publication Date: 2025-03-07BEIJING QIYI CENTURY SCI & TECH CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210262084.0
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-03-16
Publication Date
2025-03-07
Estimated Expiration
2042-03-16

AI Technical Summary

Technical Problem

When providing web pages that are adapted to different web page running environments, the server sends too much web page file data and the client loading speed is slow.

Method used

By obtaining the first web page file containing the target code, each first web page file only contains the code executed when the second web page file is run under a specific web page running environment, and the server sends the corresponding first web page file to the client according to the client's web page running environment.

Benefits of technology

This reduces the amount of web page file data sent by the server to the client, increases the speed of the client loading web page files, and thus improves the speed of web page access.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114707090B_ABST
    Figure CN114707090B_ABST
Patent Text Reader

Abstract

The embodiment of the present invention provides a web page file sending method and device, which relates to the field of network technology. The method includes: obtaining each first web page file corresponding to different web page running environments; responding to an access request from a client, and determining a target web page running environment for the client to run the requested web page file based on the access request; sending the first web page file corresponding to the target web page running environment to the client, so that the client loads and runs the received first web page file. The web page file sending method provided by the embodiment of the present invention can improve the speed at which the client loads web page files.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of network technology, and in particular to a method and device for issuing web page files. Background Art

[0002] For a web page that provides a certain service, the content that the web page needs to focus on displaying is often different depending on the web page operating environment. For example, a web page used to promote a certain product, when the operating environment of the web page is a browser, needs to focus on displaying product information and information used to direct users to a specified application, while when the operating environment of the web page is the above-mentioned specified application, it needs to focus on displaying interactive windows for specific interactions with users, such as login, order placement, and other interactive windows.

[0003] In order to meet the demand of displaying different contents in different web page operating environments on the same web page, in the related technology, developers will write branch codes under different web page operating environments in the web page file of the web page, and use code packaging tools to package these web page files into a package file, and deploy the package file to the server. Users can send access requests to the server through the client to access the above web page. For example, the above client can be a browser, WeChat, the above specified application, etc. After receiving the access request from the above client, the server can send the above package file to the client, and the client loads the above package file and runs it. In this way, the client can run the branch code corresponding to its own web page operating environment, and then display the web page content matching its own web page operating environment.

[0004] However, when a web page file contains many branch codes for different web page running environments, the data volume of the packaged web page file is large. When the user accesses the web page, the packaged file sent by the server to the client is large, which results in the client having to load the above-mentioned web page file with a large data volume and a slow loading speed. Summary of the invention

[0005] The purpose of the embodiment of the present invention is to provide a method and device for sending web page files, so as to reduce the amount of data of the web page files sent by the server to the client during the process of the client accessing the web page, thereby improving the speed of the client loading the above web page files. The specific technical solution is as follows:

[0006] In a first aspect of the present invention, a method for sending a webpage file is provided, the method comprising:

[0007] Obtaining first web page files corresponding to different web page running environments, wherein each first web page file includes: a target code, which is a code executed by a second web page file when the second web page file is running in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display a web page in each different web page running environment;

[0008] In response to an access request from a client, determining a target web page running environment for the client to run the requested web page file based on the access request;

[0009] A first webpage file corresponding to the target webpage running environment is sent to the client, so that the client loads and runs the received first webpage file.

[0010] In a second aspect of the present invention, a web page file distribution device is provided, the device comprising:

[0011] The web page file acquisition module is used to obtain various first web page files corresponding to different web page running environments, wherein each first web page file includes: target code, which is: code executed when the second web page file is running in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display the web page in each different web page running environment;

[0012] An information determination module, for responding to an access request from a client and determining, based on the access request, a target web page running environment for the client to run the requested web page file;

[0013] The web page file sending module is used to send a first web page file corresponding to the target web page running environment to the client, so that the client loads and runs the received first web page file.

[0014] In a third aspect of the present invention, an electronic device is provided, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other via the communication bus;

[0015] Memory, used to store computer programs;

[0016] The processor is used to implement any of the above-mentioned methods for sending web page files when executing the program stored in the memory.

[0017] In a fourth aspect of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, any of the above-mentioned methods for delivering web page files is implemented.

[0018] In a fifth aspect of the implementation of the present invention, a computer program product comprising instructions is also provided, which, when executed on a computer, enables the computer to execute any of the above-mentioned methods for delivering web page files.

[0019] As can be seen from the above, when the solution provided by the embodiment of the present invention is applied to send web page files, the server first obtains each first web page file corresponding to different web page operating environments, and each first web page file contains all the codes executed when the second web page file is running in a specified web page operating environment. After receiving the access request from the client, the server only needs to determine the web page operating environment of the client and send the first web page file corresponding to the client operating environment to the client. In this embodiment, the server directly sends the first web page file containing the target code that matches the web page operating environment of the client to the client, and then the client can directly run the above-mentioned first web page file, thereby realizing normal access to the web page.

[0020] In addition, since the second web page file contains codes that are executed when running in different web page running environments, and the codes in the first web page file are only part of the codes that are executed when the second web page file is running in a specified web page running environment, it can be known that the data size of the first web page file is obviously smaller than that of the second web page file. In this way, compared with the server directly sending the second web page file to the client, in this embodiment, the server sends the first web page file that matches the actual web page running environment of the client to the client, which can reduce the data size of the web page file that the server needs to send to the client, and also reduce the data size of the web page file that the client needs to load, effectively improving the client's loading speed of the above web page file, and also improving the client's access speed to the web page. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0022] Figure 1a A schematic diagram of a flow chart of a first web page file distribution method provided by an embodiment of the present invention;

[0023] Figure 1b A schematic diagram of a flow chart of a second webpage file distribution method provided by an embodiment of the present invention;

[0024] Figure 1c A schematic diagram of a flow chart of a third webpage file distribution method provided by an embodiment of the present invention;

[0025] Figure 1d A schematic diagram of a flow chart of a fourth webpage file distribution method provided by an embodiment of the present invention;

[0026] Figure 2 A schematic diagram of a fifth method for delivering a webpage file provided in an embodiment of the present invention;

[0027] Figure 3 A schematic diagram of the structure of a web page file distribution device provided by an embodiment of the present invention;

[0028] Figure 4 A schematic diagram of the structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0029] The technical solutions in the embodiments of the present invention will be described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0030] In one embodiment of the present invention, a method for delivering a webpage file is provided, the method comprising:

[0031] Obtaining first web page files corresponding to different web page running environments, wherein each first web page file includes: target code, the target code is: code executed when the second web page file runs in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display a web page in each different web page running environment;

[0032] In response to an access request from a client, determining a target web page running environment for the client to run the requested web page file based on the access request;

[0033] A first webpage file corresponding to the target webpage running environment is sent to the client, so that the client loads and runs the received first webpage file.

[0034] As can be seen from the above, when the solution provided by the embodiment of the present invention is applied to send web page files, the server first obtains each first web page file corresponding to different web page operating environments, and each first web page file contains all the codes executed when the second web page file is running in a specified web page operating environment. After receiving the access request from the client, the server only needs to determine the web page operating environment of the client and send the first web page file corresponding to the client operating environment to the client. In this embodiment, the server directly sends the first web page file containing the target code that matches the web page operating environment of the client to the client, and then the client can directly run the above-mentioned first web page file, thereby realizing normal access to the web page.

[0035] In addition, since the second web page file contains codes that are executed when running in different web page running environments, and the codes in the first web page file are only part of the codes that are executed when the second web page file is running in a specified web page running environment, it can be known that the data size of the first web page file is obviously smaller than that of the second web page file. In this way, compared with the server directly sending the second web page file to the client, in this embodiment, the server sends the first web page file that matches the actual web page running environment of the client to the client, which can reduce the data size of the web page file that the server needs to send to the client, and also reduce the data size of the web page file that the client needs to load, effectively improving the client's loading speed of the above web page file, and also improving the client's access speed to the web page.

[0036] The following is a description of the execution subject of the solution provided in the embodiment of the present invention.

[0037] The execution subject of the solution provided by the embodiment of the present invention may be: a server for receiving a web page request from a client and sending a web page file to the client.

[0038] The web page file distribution method provided by the embodiment of the present invention is described in detail below through specific embodiments.

[0039] See also Figure 1a , Figure 1a The present invention provides a flowchart of a first method for delivering a webpage file according to an embodiment of the present invention. The method includes the following steps S101-S103.

[0040] Step S101: obtaining first web page files corresponding to different web page running environments.

[0041] Among them, each first web page file contains: target code, the above target code is: code executed when the second web page file runs in the web page running environment corresponding to the first web page file, and the above second web page file contains: all codes required to be executed to display the web page in each different web page running environment.

[0042] For the convenience of description, the code executed when the second web page file is running in a certain web page running environment is referred to as the code in the certain web page running environment.

[0043] The second web page file is a web page file containing codes in various web page operating environments in the aforementioned prior art. For example, the second web page file may contain codes that run when the web page operating environment is a WeChat environment, codes that run when the web page operating environment is a browser environment, and codes that run when the web page operating environment is other specific application environments. The second web page file may include various types of files, such as HTML (HyperTextMark-up Language) files, CSS (Cascading Style Sheets), Java script language files, etc.

[0044] As can be seen from the above, the target code in the first web page file is part of the code executed when the second web page file is running in a certain web page running environment. In this way, after the server obtains each first web page file, it can send the first web page file corresponding to the web page running environment of the client that requests to access the web page to the client according to the web page running environment of the client, without sending the second web page file containing the code in each web page running environment to the client. As a result, the amount of data of the web page file received by the client is small, and the speed of loading the web page file by the client is faster.

[0045] Specifically, the server may obtain various first web page files corresponding to different web page running environments in the following manner.

[0046] In one implementation, the first web page files may be pre-packaged by any electronic device, and the electronic device may send the packaged first web page files to a server, so that the server may obtain the first web page files.

[0047] In another implementation, the server itself can process the second web page file to generate various first web page files corresponding to different web page running environments. For details, see Figure 1b and Figure 1c The illustrated embodiment will not be described in detail here.

[0048] In addition, since the first web page file corresponds to the web page operating environment, it is also possible to determine from the perspective of different web page operating environments which web page operating environments the first web page file corresponding to is obtained. The specific implementation method can be found in the subsequent description and will not be described in detail here.

[0049] Step S102: In response to the access request from the client, based on the access request, determining a target web page running environment for the client to run the requested web page file.

[0050] Specifically, the target web page running environment used by the client to run the requested web page file may be determined in the following manner.

[0051] In one implementation, the access request of the client may include an environment identifier indicating the web page running environment of the client itself. In this case, the server may directly read the environment identifier included in the access request, and according to the preset mapping relationship between the environment identifier and the web page running environment, determine the web page running environment corresponding to the read environment identifier as the target web page running environment for the client to run the requested web page file.

[0052] In another implementation, the access request of the client may include an environment number corresponding to the web page running environment of the client itself, and the value of the environment number is different from the environment identifier. For example, the environment number may be represented in the form of numbers, characters, etc. In this case, the server may read the environment number in the access request, and then, based on the preset mapping relationship between the environment number and the web page running environment, determine the web page running environment corresponding to the read environment number as the target web page running environment for the client to run the requested web page file.

[0053] Step S103: sending a first web page file corresponding to the target web page running environment to the client, so that the client loads and runs the received first web page file.

[0054] Specifically, the server can pre-record the correspondence between the storage path of each first web page file and each web page operating environment. In this way, the server can find the storage path of the first web page file corresponding to the target web page operating environment based on the above correspondence, and then access the first web page file located at the above storage path. The first web page file is the first web page file corresponding to the target web page operating environment. Sending the first web page file to the client can enable the client to load and run the received first web page file.

[0055] In another implementation manner, the first web page file may further include a first environment identifier indicating a web page running environment corresponding to the first web page file. In this case, Figure 1a Steps S102 and S103 shown in the embodiment can also be implemented through step A and step B respectively. The specific implementation methods are described in the subsequent description and will not be described in detail here.

[0056] As can be seen from the above, when the solution provided by the embodiment of the present invention is applied to send web page files, the server first obtains each first web page file corresponding to different web page operating environments, and each first web page file contains all the codes executed when the second web page file is running in a specified web page operating environment. After receiving the access request from the client, the server only needs to determine the web page operating environment of the client and send the first web page file corresponding to the client operating environment to the client. In this embodiment, the server directly sends the first web page file containing the target code that matches the web page operating environment of the client to the client, and then the client can directly run the above-mentioned first web page file, thereby realizing normal access to the web page.

[0057] In addition, since the second web page file contains codes that are executed when running in different web page running environments, and the codes in the first web page file are only part of the codes that are executed when the second web page file is running in a specified web page running environment, it can be known that the data size of the first web page file is obviously smaller than that of the second web page file. In this way, compared with the server directly sending the second web page file to the client, in this embodiment, the server sends the first web page file that matches the actual web page running environment of the client to the client, which can reduce the data size of the web page file that the server needs to send to the client, and also reduce the data size of the web page file that the client needs to load, effectively improving the client's loading speed of the above web page file, and also improving the client's access speed to the web page.

[0058] The above-mentioned method of obtaining the first web page file is described below.

[0059] In one implementation, target codes corresponding to different web page operating environments can be determined from the second web page file in sequence, and different target codes can be packaged to obtain different second web page files, thereby directly obtaining different first web page files corresponding to different web page operating environments.

[0060] In another implementation, the first web page file corresponding to a specific partial web page operating environment can also be obtained according to demand. This situation is applicable to the scenario where the target code in a first web page file has been updated. For example, first web page files corresponding to different web page operating environments have been obtained, and the target code in the first web page file corresponding to the browser environment has been updated, so it is necessary to re-acquire the first web page file corresponding to the browser environment. In this case, only the first web page file corresponding to the browser environment can be obtained, and the first web page files corresponding to other web page operating environments do not need to be obtained again.

[0061] In the case that the first web page file further includes: a first environment identifier indicating a web page running environment corresponding to the first web page file, the above-mentioned S102 and S103 can also be implemented by step A and step B respectively.

[0062] First, the meaning of the first environment identifier included in the above-mentioned first web page file is explained.

[0063] The first environment identifier contained in the first web page file is pre-set and can be used to indicate the web page running environment corresponding to the target code contained in the first web page file. For example, the first environment identifier contained in the first web page file can be wechat, indicating that the target code contained in the first web page file corresponds to the WeChat environment, or it can be browser, indicating that the target code contained in the first web page file corresponds to the browser environment, etc. Of course, the above-mentioned pre-set first environment identifier is only an example. In this embodiment, any form of identifier that can indicate the web page running environment can be set as the first environment identifier, such as a numerical value, a character, etc.

[0064] The specific implementation of the above-mentioned step A and step B is described below.

[0065] Step A: In response to an access request from a client, a second environment identifier of the client is determined based on the access request.

[0066] The web page operating environment indicated by the second environment identifier is a target web page operating environment used by the client to run the requested web page file.

[0067] Specifically, the second environment identifier of the client may be determined in the following manner.

[0068] In one implementation, the client's access request may include an environment identifier indicating the client's own webpage operating environment. In this case, the server may directly read the environment identifier included in the access request and determine the read environment identifier as the client's second environment identifier.

[0069] In another implementation, the access request of the client includes an environment number corresponding to the webpage running environment of the client itself, and the value of the environment number is different from the environment identifier, for example, the environment number can be represented in the form of numbers, characters, etc. In this case, the server can read the environment number in the access request, and then determine the environment identifier corresponding to the environment number as the second environment identifier of the client according to the preset mapping relationship between the environment number and the environment identifier.

[0070] Step B: Sending a first webpage file including a first environment identifier equal to a second environment identifier to a client, so that the client loads and runs the received first webpage file.

[0071] Since the second environment identifier of the client indicates the web page running environment of the client, the first web page file whose first environment identifier is equal to the second environment identifier is the web page file that can be run by the web page running environment of the client, so that the server can accurately determine the first web page file that needs to be sent to the client.

[0072] See also Figure 1b , is a flow chart of a second method for delivering a webpage file provided by an embodiment of the present invention, wherein Figure 1a Based on the embodiment shown, for each web page operating environment, Figure 1a Step S101 can also be performed by Figure 1b The steps S101A-S101C shown in are implemented.

[0073] Step S101A: Obtain a third web page file.

[0074] The third web page file is a copy of the second web page file.

[0075] Step S101B: deleting the code recorded in the third web page file and executed in other web page execution environments other than the web page execution environment.

[0076] In this step, the code in the web page running environment in the third web page file is retained, and the code in other web page running environments is deleted, and the remaining code is the target code of the first web page file corresponding to the web page running environment.

[0077] In one embodiment, this step can also be combined with Figure 1c The embodiment shown uses Figure 1c The operating environment variables used in the embodiment shown in the figure delete the code segment recorded in the third webpage file, whose operating condition is the environment variable value of the corresponding operating environment variable and is not the target environment identifier of the webpage operating environment. Figure 1c The illustrated embodiment will not be described in detail here.

[0078] In addition, in this embodiment, the Tree-shaking technology used in the prior art to remove redundant codes in a file during the file compilation process can be used to remove the above-mentioned code segments that need to be deleted during the compilation of the first web page file.

[0079] Step S101C: Pack the remaining codes in the third web page file to obtain the first web page file corresponding to the web page running environment.

[0080] It can be seen that after the processing of step B, the remaining code in the third web page file is the target code corresponding to the web page running environment.

[0081] Specifically, the first web page file corresponding to the web page running environment may be obtained in the following manner.

[0082] In one implementation, the above target code can be directly packaged to obtain the first web page file corresponding to the web page running environment.

[0083] In another implementation manner, the above-mentioned target code and the first environment identifier indicating the web page running environment may also be packaged into the same file to obtain a first web page file corresponding to the web page running environment.

[0084] From the above, it can be seen that after deleting the code in other web page operating environments outside the web page operating environment in the third web page file, the remaining code is the target code corresponding to the web page operating environment. By packaging the above remaining target code, the first web page file corresponding to the web page operating environment can be accurately obtained.

[0085] See also Figure 1c , is a flow chart of a third method for delivering a webpage file provided by an embodiment of the present invention, Figure 1a Based on the embodiment shown, for each web page operating environment, Figure 1a Step S101 can also be performed by Figure 1c The steps S101D and S101E shown in FIG.

[0086] First, the method of distinguishing codes corresponding to different web page running environments in web page files in the prior art is described:

[0087] In order to enable the client to determine the code contained in the web page file and matched with its actual web page running environment when running the web page file, the web page file often contains running environment variables. In order to distinguish from the running environment variables used in the subsequent embodiments, the running environment variables contained in the above web page file in the prior art are referred to as original running environment variables below. Different environment variable values ​​of the original running environment variables correspond to different web page running environments. In addition, for different code segments, the web page file often also records the running conditions of the code segment, and the above running conditions are related to the environment variable values ​​of the original running environment variables. For example, the running condition of the code segment M can be that when the above environment variable value is n, the code in the code segment M will be run in the web page running environment corresponding to the above environment variable value n. After the client obtains the web page file, when running the web page file, it can judge the running conditions of different code segments based on the values ​​of the original running environment variables corresponding to its own web page running environment, so as to determine whether the code of the code segment needs to be executed. However, in the prior art, the original operating environment variables contained in the web page file are variables that can only be accessed during the execution of the web page file. Therefore, in the prior art, the client can only determine whether each code segment needs to be executed during the execution of the web page file.

[0088] The method of obtaining the first webpage file in the embodiment of the present invention is further described:

[0089] Step S101D: during the compilation of the second web page file, determine from the second web page file that the environment variable value of the running environment variable is the code executed by the second web page file at runtime when the target environment identifier of the web page running environment is indicated, as the target code.

[0090] Different environment variable values ​​of the above operating environment variables correspond to different web page operating environments.

[0091] In this step, in order to enable the server to determine the above-mentioned target code before the second web page file is run, the operating environment variables in the second web page file used in this embodiment are variables that can be accessed by the server before the second web page file is run. In this way, before the second web page file is run and during the compilation of the second web page file, the server can access the operating environment variables in the second web page file, and take the environment variable value of the above-mentioned operating environment variable as the code executed by the second web page file at run time when the target environment identifier indicating the web page operating environment is used as the target code.

[0092] From the description of the aforementioned background technology, it can be seen that the original operating environment variables in the second web page file cannot be accessed by the server before the second web page file is run. Therefore, in order to be able to determine the target code before the second web page file is actually run, it is necessary to first replace the original operating environment variables in the second web page file with the above-mentioned operating environment variables that can be accessed before the second web page file is run.

[0093] The following describes a method for replacing the original operating environment variables in the second web page file with the operating environment variables that can be accessed before the second web page file is executed.

[0094] Specifically, there is often a configuration file in the project folder where the second web page file is located. The DefinePlugin function in the Webpack (web page packaging) tool can be used to create an operating environment variable in the above configuration file that can be accessed by the server during the web page compilation phase before the second web page file is run. And according to different web page operating environments, the above operating environment variables are pre-set with environment variable values ​​corresponding to different web page operating environments. The above environment variable values ​​can be the aforementioned pre-set environment identifiers. Then, the staff replaces the original operating environment variables in the second web page file with the above operating environment variables, and replaces the environment variable values ​​of the original operating environment variables recorded in the second web page file with the environment variable values ​​of the operating environment variables corresponding to the same web page operating environment.

[0095] After the above-mentioned variable replacement, the above-mentioned operating environment variables in the second web page file can be accessed by the server in the web page file compilation phase before the second web page file is run, and then it can be determined that when the environment variable value of the operating environment variable in the second web page file is the target environment identifier indicating the web page operating environment, the target code actually executed by the second web page file at runtime.

[0096] In addition, you can combine Figure 1b The embodiment shown deletes the code segment recorded in the third web page file that is executed when the value of the running environment variable is not the target environment identifier, thereby determining the remaining code as the target code under the running environment of the web page. For details, please see the subsequent embodiments and will not be described in detail here.

[0097] Step S101E: Pack the target code to obtain a first web page file corresponding to the web page running environment.

[0098] The above step S101E can be Figure 1b The method is obtained on the basis of step S101C of the illustrated embodiment, the only difference being that the remaining code in the third web page file is replaced with the target code, which will not be described in detail here.

[0099] From the above, it can be seen that before the second web page file runs, the server can access the running environment variables in the second web page file to accurately determine that when the environment variable value of the running environment variable in the second web page file is a target environment identifier indicating a certain web page running environment, the code executed by the second web page file at runtime is used as the target code, and the above target code can be packaged to accurately obtain the first web page file.

[0100] The following is a summary of the above combination Figure 1b and Figure 1c The illustrated embodiment specifically describes the manner in which the target code corresponding to the web page running environment is determined.

[0101] From the description of the prior art, it can be seen that the code in the second webpage file that needs to distinguish the running environment is often a code segment with running conditions, and the above running conditions are related to the environment variable value of the original running environment variable in the first webpage file. Different from the above original running environment variables, the running environment variables in the second webpage file used in this embodiment are Figure 1c After the variable replacement operation shown in step S101D, the variables that can be accessed by the device that compiles the code before the second web page file is run in the process of compiling the code. After the variable replacement, the running conditions of the above code segment in the second web page file are related to the environment variable value of the above running environment variable.

[0102] exist Figure 1b Based on the illustrated embodiment, it can be known that the third web page file is a copy of the second web page file. Before the third web page file runs, the server can access the running environment variables in the third web page file to determine whether the running condition of the above-mentioned code segment in the third web page file is that the environment variable value of the above-mentioned running environment variable is equal to the target environment identifier. If so, it means that the code in the code segment will be actually executed when running in the web page running environment indicated by the target environment identifier; if not, it means that the code in the code segment will not be actually executed when running in the web page running environment indicated by the target environment identifier. Therefore, the code segment can be deleted and the remaining code in the third web page file can be used as the target code.

[0103] Furthermore, from the above description of the prior art, it can be seen that the third web page file also includes codes for obtaining the web page operating environment of the client at runtime and conditional judgment codes for judging whether each code segment needs to be run. The role of these codes is to determine the code that needs to be executed in the web page file according to its own operating environment when the client actually runs the web page file. In this embodiment, the client can directly run all the target codes in the first web page file obtained, and does not need to determine the code segment that it needs to execute. Therefore, when determining the target code, the above-mentioned code for obtaining the web page operating environment of the client and the conditional judgment code for judging whether each code segment needs to be run are also redundant codes. These codes can be deleted together, so that the data volume of the target code is smaller, that is, the data volume of the first web page file packaged based on the target code is smaller.

[0104] See also Figure 1d , is a flow chart of a fourth web page file distribution method provided by an embodiment of the present invention, Figure 1a Based on the embodiment shown, Figure 1a Step S102 can also be performed by Figure 1d Step S102A is implemented as shown in FIG. 1 , and step S103 can also be implemented by Figure 1d Step S103A is implemented as shown.

[0105] Step S102A: obtaining an environment identifier carried in an access request from a client to access a first URL, and determining the web page running environment indicated by the environment identifier as a target web page running environment for the client to run the requested web page file.

[0106] The above-mentioned first URL (Uniform Resource Locator) is the URL of the forwarding web page provided by the server for redirecting the client's access request. The user can uniformly access the first URL of the above-mentioned forwarding web page through the client. At the same time, the server can obtain the environment identifier carried in the client's access request through the above-mentioned forwarding web page, and determine the web page operating environment indicated by the environment identifier as the target web page operating environment used by the client to run the requested web page file.

[0107] In one implementation, the access request of the client to access the first URL carries an environment number corresponding to the web page running environment of the client itself, and the value of the environment number is different from the environment identifier, for example, the environment number can be represented in the form of numbers, characters, etc. In this case, after the server obtains the environment number carried in the access request by forwarding the web page, it can determine the web page running environment corresponding to the environment number as the target web page running environment of the client for running the requested web page file according to the mapping relationship between the preset environment number and the web page running environment.

[0108] Step S103A: redirect the client's access request to the second URL, and send the first web page file pointed to by the second URL to the client, so that the client loads and runs the first web page file.

[0109] The second URL is a preset URL corresponding to each web page operating environment, and the first web page file pointed to by the second URL corresponds to the target web page operating environment.

[0110] In this step, the server can redirect the client's access request to a second URL corresponding to the target operating environment based on the determined target web page operating environment, and then send the first web page file pointed to by the second URL to the client, so that the client loads and runs the first web page file.

[0111] In this way, the server does not need to provide different URLs for the client's access in different web page running environments. Instead, it can provide a first URL of a forwarding web page that uniformly receives and redirects the client's access request. The client's access request is redirected to the second URL of the first web page file corresponding to the client's web page running environment through the forwarding web page, and the first web page file pointed to by the second URL is sent to the client, so that the client can load and run the above-mentioned first web page file. While enabling the client to access the web page normally, it is convenient for the staff to manage the URL of the web page.

[0112] See also Figure 2 , Figure 2 The fifth method for delivering a webpage file provided in the embodiment of the present invention is a flowchart, wherein the method comprises the following steps S201-S203.

[0113] Step S201: obtaining first web page files corresponding to different web page running environments and corresponding to different services.

[0114] The business corresponding to the first web page file is the business targeted by the second web page file to which the target code in the first web page file belongs.

[0115] The business targeted by the second webpage file is the function implemented by the second webpage file, for example, the business may be product promotion, video playback, etc. Different businesses have different business identifiers.

[0116] Generally speaking, each second webpage file is only for one service, and each service requires multiple second webpage files to be implemented together. For example, three second webpage files, second webpage file R, second webpage file S, and second webpage file T, jointly implement service Y. In addition, the services implemented by different second webpage files may be different. For example, second webpage file R, second webpage file S, and second webpage file T are used to implement service Y, and second webpage file U and second webpage file V are used to implement service Z.

[0117] In this step, Figure 1a Based on step S101 of the illustrated embodiment, the first web page file obtained by the server is a web page file corresponding to a specific environment and a specific business. For example, the first web page file r corresponds to the WeChat environment and business Y. In this way, the target web page operating environment used by the client to run the requested web page file and the target business requested by the client to access can be determined later, and then the first web page file sent to the client is determined based on the above information, so that the selection of the first web page file is more targeted. The specific method of obtaining the first web page file can be obtained based on the above embodiment, which will not be repeated here.

[0118] Step S202: In response to the access request from the client, based on the access request, determining a target web page running environment for the client to run the requested web page file and a target service requested to be accessed by the client.

[0119] The above method of determining the target web page operating environment used by the client to run the requested web page file is similar to Figure 1a The step S102 of the illustrated embodiment is the same and will not be described again here.

[0120] Specifically, the service requested to be accessed by the client may be determined in the following manner.

[0121] In one implementation, the client's access request may include a service identifier corresponding to the service requested by the client. In this case, the server may directly read the service identifier included in the access request, and determine the service corresponding to the read service identifier as the service requested by the client according to the preset mapping relationship between the service identifier and each service.

[0122] In another implementation, the access request of the client may include a service number corresponding to the service requested by the client, and the value of the service number is different from the service identifier. For example, the service number may be represented in the form of numbers, characters, etc. In this case, the server may read the service number in the access request, and determine the service corresponding to the read service number as the service requested by the client according to the preset mapping relationship between the service number and each service.

[0123] Step S203: sending a first web page file corresponding to the target web page running environment and the target business to the client, so that the client loads and runs the received first web page file.

[0124] In this step, Figure 1a On the basis of step S103 of the illustrated embodiment, when selecting the first web page file to be sent to the client, not only is it required that the first web page file corresponds to the target web page operating environment, but it is also required that the first web page file corresponds to the target business, that is, the first web page file whose operating environment and the targeted business both match the client's access request is selected.

[0125] For example, the web page operating environment of the client is the WeChat environment, the service requested by the client is service Y, and there are the first web page file r and the first web page file u in the WeChat environment. Among them, the first web page file r is generated by packaging the target code in the second web page file R, and the service it targets is service Y. The first web page file u is generated by packaging the target code in the second web page file U, and the service it targets is service Z. In this case, if the server determines that the above-mentioned target service is service Y, and determines that the above-mentioned target web page operating environment is the WeChat environment, the server can send the first web page file r corresponding to the client's operating environment WeChat and matching the service Y requested by the client to the client, which further reduces the amount of data of the first web page file sent to the client compared to directly sending the first web page file r and the first web page file u corresponding to the WeChat environment to the client.

[0126] Specifically, the server can pre-record the correspondence between the storage path of each first web page file and each web page operating environment and each business. In this way, the server can find the storage path of the first web page file corresponding to the target web page operating environment and the target business based on the above correspondence, and then access the first web page file located at the above storage path, and send the first web page file to the client, so that the client can load and run the received first web page file.

[0127] Since each first web page file obtained by the server corresponds not only to the web page operating environment but also to each service, the server can send the first web page file corresponding to the service accessed by the client and the web page operating environment of the client to the client, instead of directly sending all the first web page files corresponding to the web page operating environment to the client. Therefore, the first web page file sent to the client is more targeted, which is conducive to further reducing the data volume of the first web page file sent by the server to the client, and thus can improve the loading speed of the first web page file by the client.

[0128] In one embodiment of the present disclosure, the first webpage file may further include a first environment identifier and a first service identifier, where the first service identifier is a preset service identifier corresponding to the service targeted by the first webpage file.

[0129] In this case, the above steps S203 and S204 can be implemented by following steps C and D.

[0130] Step C: In response to the access request from the client, based on the access request, determine the second environment identifier of the client and the second service identifier of the service requested for access.

[0131] Step D: Sending a first webpage file including a first environment identifier equal to a second environment identifier and a first service identifier equal to a second service identifier to the client, so that the client loads and runs the received first webpage file.

[0132] Specific implementation methods can be found in Figure 1a The method is obtained on the basis of step A and step B shown in the embodiment, the only difference is that the second service identifier of the client needs to be obtained, and the first service identifier contained in the first webpage file sent to the client is also equal to the second service identifier, which will not be repeated here.

[0133] In one embodiment of the present disclosure, the aforementioned step S202 may also be implemented in the following manner:

[0134] The server can provide the user with a third URL corresponding to different services, and the web page pointed to by the third URL records the service identifier corresponding to the service. When the user clicks on a third URL, the client sends an access request to the third URL, indicating that the user wants to access the service corresponding to the third URL. In this case, the web page pointed to by the third URL can obtain the environment identifier corresponding to the client's web page operating environment carried in the client's access request, and send the environment identifier and the service identifier of the service corresponding to the third URL to the forwarding web page pointed to by the first URL. At this time, the server can determine the web page operating environment corresponding to the environment identifier as the target web page operating environment used by the client to run the requested web page file through the forwarding web page, and determine the service corresponding to the service identifier as the target service requested by the client.

[0135] In one embodiment of the present disclosure, the aforementioned step S203 may also be implemented in the following manner:

[0136] The server can redirect the access request of the client to the second URL through the forwarding webpage pointed to by the first URL, and send the first webpage file pointed to by the second URL to the client, so that the client loads and runs the first webpage file. The first webpage file pointed to by the second URL corresponds to the target webpage operating environment and the target business.

[0137] Corresponding to the above-mentioned web page file sending method, the embodiment of the present invention also provides a web page file sending device.

[0138] See also Figure 3 , Figure 3 This is a schematic diagram of the structure of a first device for generating information for advertisements provided by an embodiment of the present invention. The device includes the following modules 301-303.

[0139] The web page file obtaining module 301 is used to obtain various first web page files corresponding to different web page running environments, wherein each first web page file includes: a target code, which is: a code executed when the second web page file is running in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display a web page in each different web page running environment;

[0140] An information determination module 302 is used to respond to an access request from a client and determine a target web page running environment for the client to run the requested web page file based on the access request;

[0141] The web page file sending module 303 is used to send a first web page file corresponding to the target web page running environment to the client, so that the client loads and runs the received first web page file.

[0142] As can be seen from the above, when the solution provided by the embodiment of the present invention is applied to send web page files, the server first obtains each first web page file corresponding to different web page operating environments, and each first web page file contains all the codes executed when the second web page file is running in a specified web page operating environment. After receiving the access request from the client, the server only needs to determine the web page operating environment of the client and send the first web page file corresponding to the client operating environment to the client. In this embodiment, the server directly sends the first web page file containing the target code that matches the web page operating environment of the client to the client, and then the client can directly run the above-mentioned first web page file, thereby realizing normal access to the web page.

[0143] In addition, since the second web page file contains codes that are executed when running in different web page running environments, and the codes in the first web page file are only part of the codes that are executed when the second web page file is running in a specified web page running environment, it can be known that the data size of the first web page file is obviously smaller than that of the second web page file. In this way, compared with the server directly sending the second web page file to the client, in this embodiment, the server sends the first web page file that matches the actual web page running environment of the client to the client, which can reduce the data size of the web page file that the server needs to send to the client, and also reduce the data size of the web page file that the client needs to load, effectively improving the client's loading speed of the above web page file, and also improving the client's access speed to the web page.

[0144] In one embodiment of the present invention,

[0145] The web page file obtaining module 301 is specifically used to obtain, for each web page running environment, a first web page file corresponding to the web page running environment by the following method:

[0146] Obtain a third web page file, wherein the third web page file is: a copy of the second web page file; delete the code recorded in the third web page file and executed in other web page operating environments other than the web page operating environment; package the remaining code in the third web page file to obtain the first web page file corresponding to the web page operating environment.

[0147] From the above, it can be seen that after deleting the code in other web page operating environments outside the web page operating environment in the third web page file, the remaining code is the target code corresponding to the web page operating environment. By packaging the above remaining target code, the first web page file corresponding to the web page operating environment can be accurately obtained.

[0148] In one embodiment of the present invention,

[0149] The web page file obtaining module 301 is specifically used to obtain, for each web page running environment, the first web page file corresponding to the web page running environment by the following method:

[0150] During the compilation of the second web page file, the environment variable value of the running environment variable is determined from the second web page file to be the code executed by the second web page file at runtime when the target environment identifier of the web page running environment is indicated; the target code is packaged to obtain the first web page file corresponding to the web page running environment.

[0151] From the above, it can be seen that before the second web page file runs, the server can access the running environment variables in the second web page file to accurately determine that when the environment variable value of the running environment variable in the second web page file is a target environment identifier indicating a certain web page running environment, the code executed by the second web page file at runtime is used as the target code, and the above target code can be packaged to accurately obtain the first web page file.

[0152] In one embodiment of the present invention,

[0153] The information determination module 302 is specifically used to obtain the environment identifier carried in the access request of the client to access the first uniform resource locator URL, and determine the web page running environment indicated by the environment identifier as the target web page running environment used by the client to run the requested web page file;

[0154] The web page file sending module 303 is specifically used to redirect the client's access request to the second URL, and send the first web page file pointed to by the second URL to the client, so that the client loads and runs the first web page file, wherein the first web page file pointed to by the second URL corresponds to the target web page running environment.

[0155] In this way, the server does not need to provide different URLs for the client's access in different web page running environments. Instead, it can provide a first URL of a forwarding web page that uniformly receives and redirects the client's access request, and redirects the client's access request to the second URL of the first web page file corresponding to the client's web page running environment through the forwarding web page, so that the client can load and run the above-mentioned first web page file by accessing the second URL. While enabling the client to access the web page normally, it is convenient for the staff to manage the URL of the web page.

[0156] In one embodiment of the present invention, the first web page file further includes: a first environment identifier indicating a web page running environment corresponding to the first web page file;

[0157] The information determination module 302 is specifically configured to determine, in response to an access request from a client, a second environment identifier of the client based on the access request, wherein the web page running environment indicated by the second environment identifier is a target web page running environment for the client to run the requested web page file;

[0158] The webpage file sending module 303 is specifically configured to send a first webpage file including a first environment identifier equal to the second environment identifier to the client, so that the client loads and runs the received first webpage file.

[0159] Since the second environment identifier of the client indicates the web page running environment of the client, the first web page file whose first environment identifier is equal to the second environment identifier is the web page file that can be run by the web page running environment of the client, so that the server can accurately determine the first web page file that needs to be sent to the client.

[0160] In one embodiment of the present invention,

[0161] The web page file acquisition module 301 is specifically used to obtain various first web page files corresponding to different web page running environments and corresponding to different services;

[0162] The information determination module 302 is specifically used to respond to the access request of the client and determine the target web page running environment used by the client to run the requested web page file and the target business requested by the client to access based on the access request;

[0163] The web page file sending module 303 is specifically configured to send a first web page file corresponding to the target web page running environment and the target business to the client, so that the client loads and runs the received first web page file.

[0164] Since each first web page file obtained by the server corresponds not only to the web page operating environment but also to each service, the server can send the first web page file corresponding to the service accessed by the client and the web page operating environment of the client to the client, instead of directly sending all the first web page files corresponding to the web page operating environment to the client. Therefore, the first web page file sent to the client is more targeted, which is conducive to further reducing the data volume of the first web page file sent by the server to the client, and thus can improve the loading speed of the first web page file by the client.

[0165] The embodiment of the present invention further provides an electronic device, such as Figure 4 As shown, it includes a processor 401, a communication interface 402, a memory 403 and a communication bus 404, wherein the processor 401, the communication interface 402, and the memory 403 communicate with each other through the communication bus 404.

[0166] Memory 403, used for storing computer programs;

[0167] The processor 401 is used to implement the web page file sending method provided by the above method embodiment when executing the program stored in the memory 403.

[0168] The communication bus mentioned in the above terminal can be a Peripheral Component Interconnect (PCI) bus or an Extended Industry Standard Architecture (EISA) bus, etc. The communication bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.

[0169] The communication interface is used for communication between the above terminal and other devices.

[0170] The memory may include a random access memory (RAM) or a non-volatile memory, such as at least one disk memory. Optionally, the memory may also be at least one storage device located away from the aforementioned processor.

[0171] The above-mentioned processor can be a general-purpose processor, including a central processing unit (CPU), a network processor (NP), etc.; it can also be a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.

[0172] In another embodiment of the present invention, a computer-readable storage medium is provided, wherein a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the web page file distribution method described in any of the above embodiments is implemented.

[0173] In another embodiment provided by the present invention, a computer program product including instructions is also provided, which, when executed on a computer, enables the computer to execute the web page file sending method described in any one of the above embodiments.

[0174] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware or any combination thereof. When implemented by software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the process or function described in the embodiment of the present invention is generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable device. The computer instructions can be stored in a computer-readable storage medium, or transmitted from one computer-readable storage medium to another computer-readable storage medium. For example, the computer instructions can be transmitted from a website site, computer, server or data center to another website site, computer, server or data center by wired (e.g., coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that a computer can access or a data storage device such as a server or data center that includes one or more available media integrated. The available medium can be a magnetic medium (e.g., a floppy disk, a hard disk, a tape), an optical medium (e.g., a DVD), or a semiconductor medium (e.g., a solid-state hard disk Solid State Disk (SSD)), etc.

[0175] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the existence of other identical elements in the process, method, article or device including the elements.

[0176] Each embodiment in this specification is described in a related manner, and the same or similar parts between the embodiments can be referred to each other, and each embodiment focuses on the differences from other embodiments. In particular, for the device, electronic device, and computer-readable storage medium embodiments, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiments.

[0177] The above description is only a preferred embodiment of the present invention and is not intended to limit the protection scope of the present invention. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present invention are included in the protection scope of the present invention.

Claims

1. A method for issuing a webpage file, characterized in that: Applied to a server, the method comprises: Obtaining first web page files corresponding to different web page running environments, wherein each first web page file includes: a target code, which is a code executed by a second web page file when the second web page file is running in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display a web page in each different web page running environment; In response to an access request from a client, determining a target web page running environment for the client to run the requested web page file based on the access request; Sending a first webpage file corresponding to the target webpage running environment to the client, so that the client loads and runs the received first webpage file; The obtaining of first web page files corresponding to different web page running environments includes: For each web page operating environment, the first web page file corresponding to the web page operating environment is obtained in the following manner: Obtain a third web page file, wherein the third web page file is: a copy of the second web page file; delete the code recorded in the third web page file and executed in other web page operating environments other than the web page operating environment; package the remaining code in the third web page file to obtain the first web page file corresponding to the web page operating environment.

2. The method according to claim 1, characterized in that The obtaining of first web page files corresponding to different web page running environments includes: For each web page operating environment, the first web page file corresponding to the web page operating environment is obtained in the following manner: During the compilation of the second web page file, determining from the second web page file that the environment variable of the running environment variable has a value that indicates the target environment identifier of the web page running environment, the code executed by the second web page file at the time of running is used as the target code; The target code is packaged to obtain a first web page file corresponding to the web page running environment.

3. The method according to any one of claims 1 to 2, characterized in that: The step of responding to the access request from the client and determining, based on the access request, a target web page operating environment for the client to operate the requested web page file comprises: Obtaining an environment identifier carried in an access request of a client to access a first uniform resource locator URL, and determining a web page running environment indicated by the environment identifier as a target web page running environment for the client to run the requested web page file; The sending of the first webpage file corresponding to the target webpage running environment to the client so that the client loads and runs the received first webpage file includes: The access request of the client is redirected to a second URL, and a first web page file pointed to by the second URL is sent to the client, so that the client loads and runs the first web page file, wherein the first web page file pointed to by the second URL corresponds to the target web page running environment.

4. The method according to claim 1, characterized in that: The first web page file further includes: a first environment identifier indicating a web page running environment corresponding to the first web page file; The step of responding to the access request from the client and determining, based on the access request, a target web page running environment for the client to run the requested web page file comprises: In response to an access request from a client, determining a second environment identifier of the client based on the access request, wherein the web page running environment indicated by the second environment identifier is a target web page running environment for the client to run the requested web page file; The sending of the first webpage file corresponding to the target webpage running environment to the client so that the client loads and runs the received first webpage file includes: A first webpage file including a first environment identifier equal to the second environment identifier is sent to the client, so that the client loads and runs the received first webpage file.

5. The method according to claim 1, characterized in that The obtaining of first web page files corresponding to different web page running environments includes: Obtaining first web page files corresponding to different web page operating environments and corresponding to different services; The step of responding to the access request from the client and determining, based on the access request, a target web page running environment for the client to run the requested web page file comprises: In response to an access request from a client, based on the access request, determining a target web page running environment for the client to run the requested web page file and a target service requested to be accessed by the client; The sending of the first webpage file corresponding to the target webpage running environment to the client so that the client loads and runs the received first webpage file includes: A first webpage file corresponding to the target webpage operating environment and the target business is sent to the client, so that the client loads and runs the received first webpage file.

6. A web page file distribution device, characterized in that: Applied to a server, the device comprises: The web page file acquisition module is used to obtain various first web page files corresponding to different web page running environments, wherein each first web page file includes: target code, which is: code executed when the second web page file is running in the web page running environment corresponding to the first web page file, and the second web page file includes: all codes required to be executed to display the web page in each different web page running environment; An information determination module, for responding to an access request from a client and determining, based on the access request, a target web page running environment for the client to run the requested web page file; A web page file sending module, used for sending a first web page file corresponding to the target web page running environment to the client, so that the client loads and runs the received first web page file; The web page file acquisition module is specifically used for: For each web page operating environment, the first web page file corresponding to the web page operating environment is obtained in the following manner: Obtain a third web page file, wherein the third web page file is: a copy of the second web page file; delete the code recorded in the third web page file and executed in other web page operating environments other than the web page operating environment; package the remaining code in the third web page file to obtain the first web page file corresponding to the web page operating environment.

7. An electronic device, characterized in that: It includes a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory communicate with each other through the communication bus; Memory, used to store computer programs; A processor, for implementing the method steps described in any one of claims 1 to 5 when executing a program stored in a memory.

8. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1 to 5 are implemented.

Citation Information

Patent Citations

  • Method and device for detecting webpage running environment and storage medium

    CN102768630A

  • Data acquisition method, apparatus, computer equipment and system

    CN109145182A