WO2020034952A1 - 基于浏览器缓存机制优化网页加载速度的方法、电子设备 - Google Patents

基于浏览器缓存机制优化网页加载速度的方法、电子设备 Download PDF

Info

Publication number
WO2020034952A1
WO2020034952A1 PCT/CN2019/100387 CN2019100387W WO2020034952A1 WO 2020034952 A1 WO2020034952 A1 WO 2020034952A1 CN 2019100387 W CN2019100387 W CN 2019100387W WO 2020034952 A1 WO2020034952 A1 WO 2020034952A1
Authority
WO
WIPO (PCT)
Prior art keywords
script file
file
version control
script
background server
Prior art date
Application number
PCT/CN2019/100387
Other languages
English (en)
French (fr)
Inventor
孙悦
李天驰
李涛
Original Assignee
深圳点猫科技有限公司
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 深圳点猫科技有限公司 filed Critical 深圳点猫科技有限公司
Publication of WO2020034952A1 publication Critical patent/WO2020034952A1/zh

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F17/00Digital computing or data processing equipment or methods, specially adapted for specific functions

Definitions

  • the invention relates to the field of front-end programming languages, and in particular, to a method and an electronic device for optimizing a webpage loading speed based on a browser cache mechanism.
  • browsing the web through a browser has become a daily way of leisure or work for people. For example, watching movies online through a webpage, listening to music online through a webpage, or querying information through a webpage, and so on.
  • the loading speed of a web page is not only directly related to the speed of the network, but also related to how the browser loads the web page.
  • the browser After receiving a user's browsing or viewing request, the browser requests a webpage from a background server, and then the browser obtains the webpage and displays it.
  • This method of obtaining a webpage may easily cause the background server to crash when multiple users send requests to the background server. Therefore, the loading speed is optimized by a CDN (Content Delivery Network) system.
  • CDN Content Delivery Network
  • the CDN system can integrate comprehensive information such as network traffic, load conditions, and distance and response time to users. The user's request is redirected to the service node closest to the user, so that the user can get the required content nearby, solve the congestion of the Internet network, and improve the speed of the user to access the website.
  • an object of the present invention is to provide a method and an electronic device for optimizing a webpage loading speed based on a browser cache mechanism, and to solve the problem of poor webpage loading speed in the prior art.
  • a method for optimizing the loading speed of a webpage based on a browser cache mechanism includes:
  • the classification script file includes a first script file for caching and a second script file for directly pushing into a background server;
  • the background server After the background server receives the first script file, the second script file, and the version control file, it detects whether it is the first push;
  • the background server reads the version control file and judges whether the version control file has been updated. If not, it reads the script file cached by the browser.
  • the version control file obtains an update target script file, and loads a webpage according to the update target script file;
  • the background server updates the script file in the cache mechanism according to the received first script file, obtains an update target script file, and loads a webpage according to the update target script file.
  • the version control file includes one or more of an updated version control file, a newly added version control file, and an unupdated version control file.
  • the method includes:
  • the target script file is modified according to the updated version control file to obtain an updated target script file.
  • the cascading style sheet is used for editing a font color, a background color, and a web style of a web page.
  • the script file is obtained, and the script file is classified to obtain a classification script file.
  • the classification script file includes a first script file for caching and a second script file for direct pushing into a background server. After the step, adding the preset prefix file to the first script file, and before the step of obtaining the target script file and the cascading style sheet includes:
  • the second script file is stored in a preparation area, and after receiving an instruction to push the second script file into the background server, the second script file is pushed from the preparation area into the background server.
  • the present invention also provides an electronic device, including:
  • a processor adapted to implement the instructions
  • a storage device adapted to store a plurality of instructions adapted to be loaded and executed by a processor:
  • the classification script file includes a first script file for caching and a second script file for directly pushing into a background server;
  • the background server After the background server receives the first script file, the second script file, and the version control file, it detects whether it is the first push;
  • the background server reads the version control file and judges whether the version control file has been updated. If not, it reads the script file cached by the browser.
  • the version control file obtains an update target script file, and loads a webpage according to the update target script file;
  • the background server updates the script file in the cache mechanism according to the received first script file, obtains an update target script file, and loads a webpage according to the update target script file.
  • the version control file includes one or more of an updated version control file, a newly added version control file, and an unupdated version control file.
  • the cascading style sheet is used for editing a font color, a background color, and a web style of a web page.
  • the script file is obtained, and the script file is classified to obtain a classification script file.
  • the classification script file includes a first script file for caching and a second script file for direct pushing into a background server. After the step, adding the preset prefix file to the first script file, and before the step of obtaining the target script file and the cascading style sheet includes:
  • the second script file is stored in a preparation area, and when an instruction to push the second script file into the background server is received, the second script file is pushed from the preparation area into the background server.
  • the present invention also provides a computer program product.
  • the computer program product includes a computer program stored on a non-volatile computer-readable storage medium.
  • the computer program includes program instructions. When the program instructions are executed by a processor, the processor causes the processor to The method for optimizing webpage loading speed based on a browser cache mechanism.
  • the present invention also provides a non-volatile computer-readable storage medium.
  • the non-volatile computer-readable storage medium stores computer-executable instructions.
  • the one or more processors may be caused to execute the method for optimizing webpage loading speed based on a browser cache mechanism.
  • Beneficial effect through the method provided by the present invention, by first obtaining a script file and then classifying the script file, a first script file for caching and a second script file for directly pushing into the background server can be obtained; then, Adding a preset prefix file to the first script file to obtain a target script file and a cascading style sheet; automatically generating a corresponding version control file according to the target script file and the cascading style sheet; and then, The script file, the second script file, and the version control file are pushed (uploaded) to the background server. In this way, the background server can determine whether it is the first upload.
  • the background server When it is the first upload, the background server is based on the received first
  • the script file updates the script file in the cache mechanism to obtain an update target script file, and loads a webpage according to the update target script file; when it is not the first time to push, the background server reads the version control file and judges Whether the version control file has been updated, and if not, read the footer cached by the browser File, and if so, obtain an updated target script file according to the updated file version control, and according to the updated target script file to load the page.
  • the method provided by the present invention greatly improves the loading speed of a web page, and when a user modifies a script file, it is no longer necessary to push an unmodified script file to a background server, which greatly improves efficiency. Not only that, when the user disables or interrupts the network request, there is no need to reload all resources, thereby improving the loading speed and efficiency of the web page.
  • FIG. 1 is a flowchart of a preferred embodiment of a method for optimizing webpage loading speed based on a browser cache mechanism according to the present invention.
  • FIG. 2 is a structural block diagram of a preferred embodiment of an electronic device according to the present invention.
  • the present invention provides a method and an electronic device for optimizing the loading speed of a webpage based on a browser cache mechanism.
  • a browser cache mechanism for optimizing the loading speed of a webpage based on a browser cache mechanism.
  • a method for optimizing webpage loading speed based on a browser cache mechanism which includes:
  • the background server After receiving the first script file, the second script file, and the version control file, the background server detects whether it is the first push;
  • the background server reads the version control file and determines whether the version control file has been updated. If not, the script file cached by the browser is read. If it is, the update is performed according to the update. A later version control file obtains an update target script file, and loads a webpage according to the update target script file;
  • the background server updates the script file in the cache mechanism according to the received first script file, obtains an update target script file, and loads a webpage according to the update target script file.
  • S1, S2, S3, S4, S5, S6, and S7 in the present invention do not represent the sequence of steps, and are merely for convenience of description. Obviously, step S6 and step S7 are in a side-by-side relationship, rather than a sequential order.
  • the background server can automatically update the corresponding script file according to the version control file, obtain the target script file, and load the webpage according to the target script file. This can greatly increase the loading speed of the webpage, save time and improve efficiency.
  • the script file is in English.
  • the script file is the program code, which is generally a programming language provided by an application program.
  • the application program includes a browser (javaScript, VBScript) or a multimedia authoring tool, and the like.
  • a script file is similar to a batch file in the DOS operating system. It can combine different commands and execute them automatically and continuously in a determined order.
  • the script file is a text file, and users can use any text editor to create the script file.
  • a first script file for caching and a second script file for pushing directly into the background server can be obtained.
  • the script files include: script file A, script file B, script file C, script file D, and script file E, which are classified according to the modification date or type of the script file, for example, script file A, script file B, and script file C is used as the first script file; script file D and script file E are used as the second script file.
  • the first script file can be cached in the browser, and the second script file can be directly pushed (uploaded) to the background server.
  • the obtaining a script file and after the step S1 and before the step S2 includes:
  • the second script file is stored in a preparation area, and after receiving an instruction to push the second script file into the background server, the second script file is pushed from the preparation area into the background server.
  • the preparation area specifically refers to a memory of an electronic device. That is, the second script file is now stored in the memory of the electronic device. When the uploaded instruction or notification is received, the second script file is pushed to the background server.
  • the prefix file refers to a category name of a script file. That is, set the front file to the "front" of the script file. For example, the prefix file "01" is set in the first group of the first script file to obtain the target script file; the prefix file "02" is set in the second group of the first script file to obtain the cascading style sheet, etc. Wait.
  • the cascading style sheet is used for editing a font color, a background color, and a web style of a web page.
  • Cascading style sheets are also called style-sheets, which usually refer to files with the extension ".css". Users can edit the font color, background color, and web page style of a web page through cascading style sheets. For example, set the font color of the web page to red, the background color device to white, and the web page style to embedded.
  • the font size and font style of the text can also be set through the cascading style sheet. For example, set the font size to “14", the font style to “kai”, and so on.
  • the version control file refers to a script description file, that is, a script description.
  • a script description file that is, a script description.
  • users can view the role and category of the script file and so on through the version control file.
  • the version control file generated according to the target script file A is a; the version control file generated according to the cascading style sheet B is b.
  • the version control file includes one or more of an updated version control file, a newly added version control file, and an unupdated version control file.
  • the updated version control file refers to an updated version control file; the newly added version control file refers to a newly added version control file; and the unupdated version control file refers to a version control file that has not been updated.
  • step S3 the method includes:
  • the target script file is modified according to the updated version control file to obtain an updated target script file.
  • the user can obtain the updated version control file (update the version control file) after the user edits or modifies the version file.
  • the background server can modify the target script file according to the updated version control file to obtain the updated target script file (update the target script file).
  • the user modifies the version control file A to obtain the modified version control file, that is, the version control file B is updated. Because the version control file A is generated by the script file a, the script file a can be correspondingly updated or modified according to the updated version control file B to obtain the target script file a0.
  • step S4 after receiving an instruction to push the first script file, the second script file, and the version control file into the background server, the second script file is read from the memory, and the first script file is read from the browser. A script file and a version control file, and then push the first script file, the second script file, and the version control file into the background server. Thereby, uploading of the first script file, the second script file, and the version control file is completed.
  • step S5 after receiving the first script file, the second script file, and the version control file, the background server will detect the first script file, the second script file, and the version control file to determine whether it is the first time. Push to background server.
  • step S6 when the result of the determination in step S5 is that it is not the first push, the background server reads the uploaded version control file, and then determines whether the version control file has been updated. If the version control file is an updated version control file, that is, the version control file is an updated version control file, then obtain an update target script file according to the updated version control file, and load a web page according to the update target script file .
  • version control file If the version control file is not updated, then read the script file cached by the browser and load the webpage according to the script file.
  • step S7 when the judgment result of step S5 is: the first push, the background server updates the script file in the browser cache mechanism according to the received first script control file, so that the browser The script file in the cache mechanism is the latest script file. Then, the web page is loaded according to the latest script file.
  • the speed of loading a web page by a user is greatly improved. After the user modifies the script, it is no longer necessary to push all the script files (unmodified script files and modified script files) to the background server, thereby improving efficiency, saving time, and optimizing the loading speed of the web page.
  • the present invention further provides an electronic device 10 including:
  • a processor 110 adapted to implement instructions
  • the storage device 120 is adapted to store a plurality of instructions, and the instructions are adapted to be loaded and executed by a processor:
  • the classification script file includes a first script file for caching and a second script file for directly pushing into a background server;
  • the background server After the background server receives the first script file, the second script file, and the version control file, it detects whether it is the first push;
  • the background server reads the version control file and judges whether the version control file has been updated. If not, it reads the script file cached by the browser.
  • the version control file obtains an update target script file, and loads a webpage according to the update target script file;
  • the background server updates the script file in the cache mechanism according to the received first script file, obtains an update target script file, and loads a webpage according to the update target script file.
  • the processor 110 may be a general-purpose processor, a digital signal processor (DSP), an application specific integrated circuit (ASIC), a field programmable gate array (FPGA), a single-chip microcomputer, an ARM (Acorn, RISC, Machine) or other programmable logic device, Discrete gate or transistor logic, discrete hardware components, or any combination of these components.
  • the processor can be any conventional processor, microprocessor, or state machine.
  • a processor may also be implemented as a combination of computing devices, eg, a combination of a DSP and a microprocessor, multiple microprocessors, one or more microprocessors in conjunction with a DSP core, any other such configuration.
  • the storage device 120 may be used to store non-volatile software programs, non-volatile computer executable programs, and modules, as optimized by a browser-based cache mechanism in the embodiment of the present invention.
  • Program instructions corresponding to the method of web page loading speed.
  • the processor executes various functional applications and data processing based on the browser cache mechanism to optimize the loading speed of the webpage by running non-volatile software programs, instructions, and units stored in the storage device. Browser caching method to optimize the loading speed of web pages.
  • the version control file includes one or more of an updated version control file, a newly added version control file, and an unupdated version control file.
  • the cascading style sheet is used for editing a font color, a background color, and a web style of a web page.
  • the script file is obtained, and the script file is classified to obtain a classification script file.
  • the classification script file includes a first script file for caching and a second script file for direct pushing into a background server. After the step, adding the preset prefix file to the first script file, and before the step of obtaining the target script file and the cascading style sheet includes:
  • the second script file is stored in a preparation area, and when an instruction to push the second script file into the background server is received, the second script file is pushed from the preparation area into the background server.
  • the present invention also provides a computer program product.
  • the computer program product includes a computer program stored on a non-volatile computer-readable storage medium.
  • the computer program includes program instructions. When the program instructions are executed by a processor, the processor causes the processor to The method for optimizing webpage loading speed based on a browser cache mechanism.
  • the present invention also provides a non-volatile computer-readable storage medium.
  • the non-volatile computer-readable storage medium stores computer-executable instructions.
  • the one or more processors may be caused to execute the method for optimizing webpage loading speed based on a browser cache mechanism.

Landscapes

  • Engineering & Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • Theoretical Computer Science (AREA)
  • Data Mining & Analysis (AREA)
  • Databases & Information Systems (AREA)
  • Mathematical Physics (AREA)
  • Software Systems (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Information Transfer Between Computers (AREA)

Abstract

本发明公开基于浏览器缓存机制优化网页加载速度的方法、电子设备,其包括:获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入。本发明提供的方法,大大提高了网页加载的速度、提高了效率和节约了时间。

Description

基于浏览器缓存机制优化网页加载速度的方法、电子设备 技术领域
本发明涉及前端编程语言领域,尤其涉及基于浏览器缓存机制优化网页加载速度的方法、电子设备。
背景技术
随着科技不断进步以及生活水平的提高,通过浏览器浏览网页已经成为人们日常的休闲或工作方式。例如,通过网页在线观看电影、通过网页在线听音乐或通过网页查询资料等等。
网页的加载速度除了与网速有直接关系外,还与浏览器加载网页的方式的有关。现有技术中,浏览器在接收用户的浏览或查看请求后,然后向后台服务器请求网页,然后浏览器获取网页,并显示。
这种获取网页的方式,当多个用户向后台服务器发送请求时,容易造成后台服务器崩溃。因此,通过CDN(Content Delivery Network)系统的方式优化加载速度。通过在网络各处放置节点服务器,也就是说,在现有的互联网基础之上的建立一层智能虚拟网络,CDN系统能够根据网络流量、负载状况以及到用户的距离和响应时间等综合信息将用户的请求重新导向离用户最近的服务节点上,使用户可就近取得所需内容,解决Internet网络拥挤的状况,提高用户访问网站的速度。
然而,部分网页使用CDN系统优化后,加载网页的速度依旧不理想。并且,用户在修改脚本文件后,没有修改的脚本文件也需要重新推入CDN系统,影响网页加载速度。此外,当用户禁止网络请求后,需要重新加载全部资源,影响网页加载速度。
因此,现有技术还有待于改进和发展。
发明内容
鉴于上述现有技术的不足,本发明的目的在于提供基于浏览器缓存机制优化网页加载速度的方法、电子设备,旨在解决现有技术中网页加载速度不佳的问题。
本发明的技术方案如下:
一种基于浏览器缓存机制优化网页加载速度的方法,其包括:
获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
优选的,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
优选的,所述根据所述目标脚本文件和层叠样式表生成对应的版本控制文件的步骤之后包括:
接收用户对版本控制文件进行修改的指令,对所述未更新版本控制文件进行修改,得到所述更新版本控制文件;
根据所述更新版本控制文件对目标脚本文件进行修改,得到更新目标脚本文件。
优选的,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。
优选的,所述获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件的步骤之后、所述将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表步骤之前包括:
将所述第二脚本文件存储至一预备区,并在接收到将第二脚本文件推入后台服务器的指令后,将所述第二脚本文件从所述预备区推入所述后台服务器。
本发明还提供一种电子设备,其包括:
处理器,适于实现各指令,以及
存储设备,适于存储多条指令,所述指令适于由处理器加载并执行:
获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
优选的,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
优选的,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。
优选的,所述获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件的步骤之后、所述将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表步骤之前包括:
将所述第二脚本文件存储至一预备区,当接收到将第二脚本文件推入后台服务器的指令时,将所述第二脚本文件从所述预备区推入所述后台服务器。
本发明还提供一种计算机程序产品,计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,计算机程序包括程序指令,当程序指令被处理器执行时,使所述处理器所述的基于浏览器缓存机制优化网页加载速度的方法。
本发明还提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个 或多个处理器执行时,可使得所述一个或多个处理器执行所述的基于浏览器缓存机制优化网页加载速度的方法。
有益效果:通过本发明提供的方法,通过先获取脚本文件,然后对脚本文件进行分类,便可以得到用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;然后,将预先设置的前缀文件添加至第一脚本文件中,从而得到目标脚本文件和层叠样式表;自动根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;再然后,将所述第一脚本文件、第二脚本文件和版本控制文件推入(上传至)后台服务器,这样,后台服务器便可以判断是否为第一次上传,当是第一上传时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页;当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页。本发明提供的方法,大大提高了网页加载的速度,并且,当用户对脚本文件进行修改时,不再需要将未修改的脚本文件推入后台服务器,大大提高了效率。不仅如此,当用户禁止或中断网络请求时,也不需要重新加载全部资源,从而提高了网页加载速度和效率。
附图说明
图1为本发明基于浏览器缓存机制优化网页加载速度的方法较佳实施例的流程图。
图2为本发明一种电子设备较佳实施例的结构框图。
具体实施方式
本发明提供基于浏览器缓存机制优化网页加载速度的方法、电子设备,为使本发明的目的、技术方案及效果更加清楚、明确,以下对本发明进一步详细说明。应当理解,此处所描述的具体实施例仅仅用以解释本发明,并不用于限定本发明。
请参阅图1,一种基于浏览器缓存机制优化网页加载速度的方法,其包括:
S1、获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
S2、将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
S3、根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
S4、将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
S5、后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
S6、当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
S7、当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
需要说明的是,本发明的中S1、S2、S3、S4、S5、S6和S7并不代表步骤的先后顺序,仅仅是为了方便说明。显然步骤S6和步骤S7是并列的关系,而不是先后的顺序。
通过本发明提供的方法,用户在修改脚本后,不再需要将所有的脚本文件(修改后的脚本文件和未修改的脚本文件)推入后台服务器,只需将修改后的版本控制文件上传至后台服务器,后台服务器便可根据版本控制文件自动更新对应脚本文件,得到目标脚本文件,从而根据目标脚本文件加载网页。这边,便可大大提高了网页的加载速度,节约了时间,提高了效率。
所述步骤S1中,脚本文件英文为Script。实际上脚本文件就是程序代码,一般都是由应用程序提供的编程语言,应用程序包括浏览器(javaScript、VBScript)或多媒体创作工具等等。脚本文件类似于DOS操作系统中的批处理文件,它可以将不同的命令组合起来,并按确定的顺序自动连续地执行。脚本文件是文本文件,用户可使用任一文本编辑器来创建脚本文件。
先对脚本文件进行分类,便可得到用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件。例如,脚本文件包括:脚本文件A、脚本文件B、脚本文件C、脚本文件D和脚本文件E,根据脚本文件的修改日期或种类进行分类,例如,将脚本文件A、脚本文件B和脚本文件C作为第一脚本文件;将脚本文件D和脚本文件E作为第二脚本文件。其中,第一脚本文件可以缓存在浏览器中,第二脚本文件可以直接推入(上传)至后台服务器中。
优选的,所述获取脚本文件,并对所述步骤S1之后、步骤S2之前包括:
将所述第二脚本文件存储至一预备区,并在接收到将第二脚本文件推入后台服务器的指令后,将所述第二脚本文件从所述预备区推入所述后台服务器。
所述预备区具体是指电子设备的内存。也就是说,现将第二脚本文件存储在电子设备的内存中。在接收到上传的指令或通知时,便将第二脚本文件推入后台服务器。
所述步骤S2中,所述前缀文件是指脚本文件的分类名称。也就是说,将前置文件设置在脚本文件的“前面”。例如,将前缀文件“01”设置于第一脚本文件的第一组中,从而得到目标脚本文件;将前缀文件“02”设置于第一脚本文件的第二组中,从而得到层叠样式表等等。
优选的,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。层叠样式表也叫做style-sheet,通常指的是指后缀名为“.css”的文件。用户可通过层叠样式表编辑网页的字体颜色、背景颜色和网页样式。例如,将网页的字体颜色设置为红色,背景颜色设备为白色,网页样式设置为嵌入式。
优选的,还可通过所述层叠样式表设置文字的字号和字体样式。例如,将字体的字号设置为“14”号,字体样式为“楷体”等等。
所述步骤S3中,所述版本控制文件是指脚本说明文件,即脚本说明。也就是说,用户可通过版本控制文件查看该脚本文件的作用和类别等等。
例如,根据目标脚本文件A生成的版本控制文件为a;根据层叠样式表B生成的版本控制文件为b。
优选的,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
所述更新版本控制文件是指更新后的版本控制文件;所述新增版本控制文件是指新添加的版本控制文件;所述未更新版本控制文件是指尚未更新的版本控制文件。
优选的,所述步骤S3之后包括:
接收用户对版本控制文件进行修改的指令,对所述未更新版本控制文件进行修改,得到所述更新版本控制文件;
根据所述更新版本控制文件对目标脚本文件进行修改,得到更新目标脚本文件。
当用户对版本控制文件进行修改时,也就是说,对版本控制文件进行 更新,那么在用户对版本文件编辑或修改后,便可以得到更新后的版本控制文件(更新版本控制文件)。
然后,后台服务器便可以根据更新版本控制文件对目标脚本文件进行修改,得到更新后的目标脚本文件(更新目标脚本文件)。
例如,用户对版本控制文件A进行修改,得到修改后的版本控制文件,即更新版本控制文件B。由于,版本控制文件A是由脚本文件a生成的,那么便可以根据更新版本控制文件B对脚本文件a进行相应的更新或修改,得到目标脚本文件a0。
所述步骤S4中,在接收到将第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器的指令后,从内存中读取第二脚本文件,从浏览器中读取第一脚本文件和版本控制文件,然后将第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器。从而,完成第一脚本文件、第二脚本文件和版本控制文件的上传。
所述步骤S5中,后台服务器在接收到第一脚本文件、第二脚本文件和版本控制文件后,将对第一脚本文件、第二脚本文件和版本控制文件进行检测,判断是否为第一次推入至后台服务器。
所述步骤S6中,当所述步骤S5的判断结果为:不是第一次推入,后台服务器便读取上传的版本控制文件,然后判断版本控制文件是否已更新。如果,版本控制文件为更新版本控制文件,也就是说,版本控制文件是更新后的版本控制文件,那么根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
如果,版本控制文件没有更新,那么读取浏览器缓存的脚本文件,并根据该脚本文件进行加载网页。
所述步骤S7中,当所述步骤S5的判断结果为:是第一次推入,后台服务器便根据接收到的第一脚本控制文件对浏览器缓存机制中的脚本文件进行更新,使得浏览器缓存机制中的脚本文件为最新的脚本文件。然后, 根据最新的脚本文件加载网页。
通过本发明提供的方法,用户加载网页的速度大大得到提升。在用户修改脚本后,不再需要将所有的脚本文件(未修改的脚本文件和修改后的脚本文件)推入后台服务器,从而提高了效率,节约了时间,并且,优化了网页的加载速度。
请参阅图2,本发明还提供一种电子设备10,其包括:
处理器110,适于实现各指令,以及
存储设备120,适于存储多条指令,所述指令适于由处理器加载并执行:
获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
所述处理器110可以为通用处理器、数字信号处理器(DSP)、专用集成 电路(ASIC)、现场可编程门阵列(FPGA)、单片机、ARM(Acorn RISC Machine)或其它可编程逻辑器件、分立门或晶体管逻辑、分立的硬件组件或者这些部件的任何组合。还有,处理器还可以是任何传统处理器、微处理器或状态机。处理器也可以被实现为计算设备的组合,例如,DSP和微处理器的组合、多个微处理器、一个或多个微处理器结合DSP核、任何其它这种配置。
存储设备120作为一种非易失性计算机可读存储介质,可用于存储非易失性软件程序、非易失性计算机可执行程序以及模块,如本发明实施例中的基于浏览器缓存机制优化网页加载速度的方法对应的程序指令。处理器通过运行存储在存储设备中的非易失性软件程序、指令以及单元,从而执行基于浏览器缓存机制优化网页加载速度的各种功能应用以及数据处理,即实现上述方法实施例中的基于浏览器缓存机制优化网页加载速度的方法。
优选的,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
优选的,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。
优选的,所述获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件的步骤之后、所述将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表步骤之前包括:
将所述第二脚本文件存储至一预备区,当接收到将第二脚本文件推入后台服务器的指令时,将所述第二脚本文件从所述预备区推入所述后台服务器。
关于上述电子设备10的具体技术细节,已在上述步骤中详述,故此不做赘述。
本发明还提供一种计算机程序产品,计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,计算机程序包括程序指令,当程序指令被处理器执行时,使所述处理器所述的基于浏览器缓存机制优化网页加载速度的方法。
本发明还提供了一种非易失性计算机可读存储介质,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个或多个处理器执行时,可使得所述一个或多个处理器执行所述的基于浏览器缓存机制优化网页加载速度的方法。
应当理解的是,本发明的应用不限于上述的举例,对本领域普通技术人员来说,可以根据上述说明加以改进或变换,所有这些改进和变换都应属于本发明所附权利要求的保护范围。

Claims (10)

  1. 一种基于浏览器缓存机制优化网页加载速度的方法,其特征在于,包括:
    获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
    将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
    根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
    将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
    后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
    当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
    当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
  2. 根据权利要求1所述基于浏览器缓存机制优化网页加载速度的方法,其特征在于,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
  3. 根据权利要求2所述基于浏览器缓存机制优化网页加载速度的方法,其特征在于,所述根据所述目标脚本文件和层叠样式表生成对应的版本控制文件的步骤之后包括:
    接收用户对版本控制文件进行修改的指令,对所述未更新版本控制文件进行修改,得到所述更新版本控制文件;
    根据所述更新版本控制文件对目标脚本文件进行修改,得到更新目标脚本文件。
  4. 根据权利要求1所述基于浏览器缓存机制优化网页加载速度的方法,其特征在于,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。
  5. 根据权利要求1所述基于浏览器缓存机制优化网页加载速度的方法,其特征在于,所述获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件的步骤之后、所述将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表步骤之前包括:
    将所述第二脚本文件存储至一预备区,并在接收到将第二脚本文件推入后台服务器的指令后,将所述第二脚本文件从所述预备区推入所述后台服务器。
  6. 一种电子设备,其特征在于,包括:
    处理器,适于实现各指令,以及
    存储设备,适于存储多条指令,所述指令适于由处理器加载并执行:
    获取脚本文件,并对所述脚本文件进行分类,得到分类脚本文件,所述分类脚本文件包括用于缓存的第一脚本文件和用于直接推入后台服务器的第二脚本文件;
    将预设的前缀文件添加至所述第一脚本文件中,得到目标脚本文件和层叠样式表;
    根据所述目标脚本文件和层叠样式表生成对应的版本控制文件;
    将所述第一脚本文件、第二脚本文件和版本控制文件推入所述后台服务器;
    后台服务器在接收到所述第一脚本文件、第二脚本文件和版本控制文件后,检测是否为第一次推入;
    当不是第一次推入时,后台服务器读取所述版本控制文件,并判断所述版本控制文件是否已更新,若否,则读取浏览器缓存的脚本文件,若是,则根据更新后的版本控制文件获取更新目标脚本文件,并根据所述更新目标脚本文件加载网页;
    当是第一次推入时,后台服务器则根据接收到的第一脚本文件对缓存机制中的脚本文件进行更新,得到更新目标脚本文件,并根据所述更新目标脚本文件加载网页。
  7. 根据权利要求6所述电子设备,其特征在于,所述版本控制文件包括更新版本控制文件、新增版本控制文件和未更新版本控制文件的一种或几种。
  8. 根据权利要求6所述电子设备,其特征在于,所述层叠样式表用于编辑网页的字体颜色、背景颜色和网页样式。
  9. 一种计算机程序产品,计算机程序产品包括存储在非易失性计算机可读存储介质上的计算机程序,计算机程序包括程序指令,当程序指令被处理器执行时,使所述处理器执行权利要求1-5任一项所述的基于浏览器缓存机制优化网页加载速度的方法。
  10. 一种非易失性计算机可读存储介质,其特征在于,所述非易失性计算机可读存储介质存储有计算机可执行指令,该计算机可执行指令被一个或多个处理器执行时,可使得所述一个或多个处理器执行权利要求1-5任一项所述的基于浏览器缓存机制优化网页加载速度的方法。
PCT/CN2019/100387 2018-08-15 2019-08-13 基于浏览器缓存机制优化网页加载速度的方法、电子设备 WO2020034952A1 (zh)

Applications Claiming Priority (2)

Application Number Priority Date Filing Date Title
CN201810930394.9 2018-08-15
CN201810930394.9A CN109002557B (zh) 2018-08-15 2018-08-15 基于浏览器缓存机制优化网页加载速度的方法、电子设备

Publications (1)

Publication Number Publication Date
WO2020034952A1 true WO2020034952A1 (zh) 2020-02-20

Family

ID=64592754

Family Applications (1)

Application Number Title Priority Date Filing Date
PCT/CN2019/100387 WO2020034952A1 (zh) 2018-08-15 2019-08-13 基于浏览器缓存机制优化网页加载速度的方法、电子设备

Country Status (2)

Country Link
CN (1) CN109002557B (zh)
WO (1) WO2020034952A1 (zh)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN109002557B (zh) * 2018-08-15 2020-12-04 深圳点猫科技有限公司 基于浏览器缓存机制优化网页加载速度的方法、电子设备
CN109800372B (zh) * 2019-01-03 2020-12-29 北京字节跳动网络技术有限公司 提升第三方网页打开速度的方法、装置及电子设备

Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN102109989A (zh) * 2009-12-29 2011-06-29 阿里巴巴集团控股有限公司 一种控制浏览器缓存的方法、装置和系统
US20130013990A1 (en) * 2005-07-15 2013-01-10 Nigel Green Browser-based retrieval and display of content associated with a link that matches a link signature
CN103365945A (zh) * 2012-03-29 2013-10-23 乐金信世股份有限公司 脚本管理方法、执行它的服务器和存储它的记录介质
CN107229655A (zh) * 2016-03-25 2017-10-03 北京京东尚科信息技术有限公司 页面静态文件的更新方法、装置及系统
CN108228282A (zh) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 用于网站页面加载的方法及装置
CN109002557A (zh) * 2018-08-15 2018-12-14 深圳点猫科技有限公司 基于浏览器缓存机制优化网页加载速度的方法、电子设备

Family Cites Families (4)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US9697189B2 (en) * 2013-11-15 2017-07-04 Instart Logic, Inc. Partial website optimization for a web publisher
US10013497B1 (en) * 2013-12-20 2018-07-03 Google Llc Background reloading of currently displayed content
US20160012144A1 (en) * 2014-07-10 2016-01-14 MyMojo Corporation Javascript-based, client-side template driver system
CN105049486B (zh) * 2015-06-16 2019-03-26 腾讯科技(北京)有限公司 静态文件的版本管理方法、装置及系统

Patent Citations (6)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
US20130013990A1 (en) * 2005-07-15 2013-01-10 Nigel Green Browser-based retrieval and display of content associated with a link that matches a link signature
CN102109989A (zh) * 2009-12-29 2011-06-29 阿里巴巴集团控股有限公司 一种控制浏览器缓存的方法、装置和系统
CN103365945A (zh) * 2012-03-29 2013-10-23 乐金信世股份有限公司 脚本管理方法、执行它的服务器和存储它的记录介质
CN107229655A (zh) * 2016-03-25 2017-10-03 北京京东尚科信息技术有限公司 页面静态文件的更新方法、装置及系统
CN108228282A (zh) * 2018-04-04 2018-06-29 北京三快在线科技有限公司 用于网站页面加载的方法及装置
CN109002557A (zh) * 2018-08-15 2018-12-14 深圳点猫科技有限公司 基于浏览器缓存机制优化网页加载速度的方法、电子设备

Also Published As

Publication number Publication date
CN109002557A (zh) 2018-12-14
CN109002557B (zh) 2020-12-04

Similar Documents

Publication Publication Date Title
US20220038550A1 (en) Method and Apparatus for Automatically Optimizing the Loading of Images in a Cloud-Based Proxy Service
US11328114B2 (en) Batch-optimized render and fetch architecture
US10185704B2 (en) Webpage browsing method, webapp framework, method and device for executing javascript and mobile terminal
JP6416374B2 (ja) 動的コンテンツと古いコンテンツとを含んでいるウェブサイトの高速レンダリング
US9077681B2 (en) Page loading optimization using page-maintained cache
US9916285B2 (en) Generating a preview of a web page for a mobile terminal
WO2015161658A1 (zh) 网页资源加载方法及装置
JP6203374B2 (ja) ウェブページ・スタイルアドレスの統合
CN104981800A (zh) 在页检索事件期间递送和显示页面预览
WO2013178094A1 (zh) 页面显示方法及装置
US8516041B1 (en) Pre-fetching asynchronously requested content
US10938879B2 (en) Third-party Ad acceleration
US10423710B2 (en) Browser plug-in with document modification and feedback capability
WO2017219524A1 (zh) 一种页面保存的方法及电子设备
WO2020034952A1 (zh) 基于浏览器缓存机制优化网页加载速度的方法、电子设备
TW201804340A (zh) 腳本生成方法與裝置
US20200151227A1 (en) Computing system with dynamic web page feature
TW201207639A (en) Late resource localization binding for web services
US20220237042A1 (en) Resource pre-fetch using age threshold
US20190317970A1 (en) Content search engine
TW201525740A (zh) 網頁顯示方法和裝置及電腦可讀取儲存介質
JP2018160264A (ja) バッチ最適化レンダリング及びフェッチアーキテクチャ
US9881101B2 (en) Dynamic file retrieving for web page loading
US20130246571A1 (en) Store Client Side Data

Legal Events

Date Code Title Description
121 Ep: the epo has been informed by wipo that ep was designated in this application

Ref document number: 19849704

Country of ref document: EP

Kind code of ref document: A1

NENP Non-entry into the national phase

Ref country code: DE

32PN Ep: public notification in the ep bulletin as address of the adressee cannot be established

Free format text: NOTING OF LOSS OF RIGHTS PURSUANT TO RULE 112(1) EPC (EPO FORM 1205 DATED 18/06/2021)

122 Ep: pct application non-entry in european phase

Ref document number: 19849704

Country of ref document: EP

Kind code of ref document: A1