Webpage resource bundle uploading method and device
A technology for webpage resources and resource packages, applied in the field of webpage resource package uploading devices and webpage resource package uploading, can solve the problem of wasting CDN server space, etc., and achieve the effect of improving space utilization.
- Summary
- Abstract
- Description
- Claims
- Application Information
AI Technical Summary
Problems solved by technology
Method used
Image
Examples
Embodiment 1
[0085] refer to figure 1 , which shows a flow chart of the steps of an embodiment of a method for uploading a web page resource package according to an embodiment of the present invention, which may specifically include the following steps:
[0086] Step S110, acquiring a webpage resource package.
[0087] In practical applications, if a user wants to access a certain webpage, he can send a webpage access request to the web server through the client, and the web server can return HTML (HyperTextMarkupLanguage, hypertext markup language) code to the client. When the browser parses the HTML code, it needs to load the corresponding web page resource package, such as a JS (JavaScript) file, a CSS file, and the like. When executing these web page resource bundles, the images referenced therein need to be loaded.
[0088] For live webpages, in order to enable users to quickly access the webpage resource packages and reduce delays, the above webpage resource packages need to be up...
Embodiment 2
[0116]参照图2,示出了根据本发明一个实施例的一种网页资源包上传方法实施例的步骤流程图,具体可以包括如下步骤:
[0117]步骤S210,上传客户端获取网页资源包。
[0118]该网页资源包包括JavaScript组合资源包;所述JavaScript组合资源包是通过打包工具将多个JavaScript资源包合并获得。
[0119]步骤S220,上传客户端对于各网页资源包,获取所述网页资源包中各第一图片地址对应的图片,并将所述图片进行归一化。
[0120]在本发明实施例中,对于各个网络资源包,可以遍历其中的每行代码,逐个根据网络资源包中各图片在本地的服务器中的第一图片地址,获取图片暂存到上传客户端中;然后对这些暂存的图片进行归一化,相同的图片只存一份。
[0121]优选的,步骤S220,具体包括:
[0122]子步骤S221,计算各图片的MD5值。
[0123]其中的MD5是Message-DigestAlgorithm5,信息摘要算法5。MD5可以将整个文件当作一个大文本信息,也可以针对一段字符串,通过其不可逆的字符串变换算法,计算出这个文件或字符串唯一的MD5值。由此可见MD5值具有唯一性。
[0124]对于图片而言,MD5值的唯一性具体是指,不同图片的MD5值是唯一且互不相同的,而同样图片的MD5值是一样的。
[0125]在实际应用中,可以利用MD5值计算器,如完美MD5计算器等,计算各路经信息的MD5值。当然,也可以采用其他的算法对图片进行归一化,本发明实施例不对其加以限制。。
[0126]子步骤S222,将相同MD5值的图片进行归一化。
[0127]由MD5值的唯一性,所以可以利用图片的MD5值将图片进行归一化,具体为对于MD5相同的各图片,只保留其中一个图片。在本发明实施例中,可以选择保留首次计算出MD5值的图片,而不保留重复计算出MD5值的图片。当然,对于归一化可以有很多种具体方式,对此,本发明不加以限定。
[0128]例如,经步骤S221计算出的各图片的MD5值如表(1):
[0129]图片 MD5值 图片1 0ca175b9c0f726a831d895e269332461 图片2 0eerq874t97qdhsyhc1d895eu945985d 图片3 5u99w4hfsiyt9wy5tw909r0q4q4vt850 图片4 0ca175b9c0f726a831d89...
Embodiment 3
[0165]参照图3,示出了根据本发明一个实施例的一种网页资源包上传方法实施例的步骤流程图,具体可以包括如下步骤:
[0166]步骤S310,上传客户端获取网页资源包。
[0167]该网页资源包包括该网页资源包包括JavaScript组合资源包;所述JavaScript组合资源包是通过打包工具将多个JavaScript资源包合并获得。
[0168]步骤S320,上传客户端对于各网页资源包,将所述网页资源包中各第一图片地址,按第一图片地址进行归一化。
[0169]在本发明实施例中,对于各个网络资源包,可以遍历其中的每行代码,读取其中的各个第一图片地址,然后对这些第一图片地址进行归一化。
[0170]优选的,步骤S320,具体包括:
[0171]子步骤S321,逐行读取所述网页资源包中的代码,判断是否有包括图片格式的路径信息。
[0172]所述图片格式包括:jpg图片格式、和 / 或PNG图片格式。当然,还可能包括其他格式,本发明不对其加以限制。
[0173]在本发明实施例中,网页资源包中包含由JavaScript资源包合并而成的JavaScript组合资源包,其中的JavaScript资源包为一系列代码行,其中可以包括图片格式的路径信息。
[0174]在本发明实施例中,图片格式包括jpg图片格式、和 / 或PNG图片格式。其中jpg图片格式的路径信息一般是一段以".jpg”结尾的代码,PNG图片格式则一般是一段以".png”结尾的代码。
[0175]例如,http: / / p1.qhimg.com / t01e1863ffab91d5971.jpg为一个jpg图片格式的路径信息;http: / / p1.qhimg.com / t010a8d81330826f08e.png为一个PNG图片格式的路径信息。
[0176]在本发明实施例中,可以利用上述的".jpg”和".png”判断网页资源包中的代码中是否有包括图片格式的路径信息。当然,也可以采用其他的方式判断,对此本发明不加以限定。
[0177]子步骤S322,如果有包括图片格式的路径信息,则确认所述包括图片格式的路径信息为第一图片地址并进行记录。
[0178]在本发明实施例中,对于包括图片格式的路径信息,即为本发明实施例所述的第一图片地址,可以将其记录在消息队列中。
[0179]子步骤S323,对于记录的各路径信息,将相同的路径信息归一化为一个路径信息。
[0180...
PUM
Abstract
Description
Claims
Application Information
- R&D Engineer
- R&D Manager
- IP Professional
- Industry Leading Data Capabilities
- Powerful AI technology
- Patent DNA Extraction
Browse by: Latest US Patents, China's latest patents, Technical Efficacy Thesaurus, Application Domain, Technology Topic.
© 2024 PatSnap. All rights reserved.Legal|Privacy policy|Modern Slavery Act Transparency Statement|Sitemap