Picture loading method and device, equipment and medium

By intercepting the client's image loading request, using the preset image proxy to detect and modify the image URL address, and obtaining the image format pictures, it solves the problems of large traffic consumption and low loading efficiency caused by repeated download of image resources in the existing technology, and achieves the following Efficient image loading.

CN119135762APending Publication Date: 2024-12-13深圳市分期乐网络科技有限公司
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410991329.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-07-23
Publication Date
2024-12-13

AI Technical Summary

Technical Problem

In the prior art, repeated download of image resources leads to high traffic consumption and low loading efficiency, and developers are prone to ignore downloading of image resource files, resulting in slow page loading and poor use.

Method used

Intercept the client's image loading request, detect the image URL address through the preset image agent, determine whether it meets the preset modification requirements, and modify it address, obtain the target URL address, access the target image in the target format, and send it to the client to load to display page.

Benefits of technology

By reducing image size, saving bandwidth costs, improving request response speed, and improving image loading efficiency, the problems of large traffic consumption and low loading efficiency are solved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119135762A_ABST
    Figure CN119135762A_ABST
Patent Text Reader

Abstract

The invention relates to the technical field of page loading, and discloses a picture loading method, device, equipment and medium, the method comprises the following steps: intercepting a picture loading request of a client, determining an application type of the client according to an access path in the picture loading request, and determining a preset picture agent corresponding to the application type; performing detection processing on a picture URL address in the picture loading request through a preset picture agent, and judging whether the picture URL address meets a preset modification requirement or not according to a detection processing result; when the picture URL address meets a preset modification requirement, performing address modification on the picture URL address to obtain a target URL address; and accessing according to the target URL address to obtain a target picture in a target format, and sending the target picture to the client so as to load the target picture to a display page after the target picture is rendered at the client. By adopting the picture in the target format, the size of the picture is reduced, the bandwidth cost is saved, the request response speed is increased, and the picture loading efficiency is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the technical field of page loading, and in particular to a method, device, equipment and medium for loading an image. Background Art

[0002] CDN (Content Delivery Network) is an Internet content distribution technology that quickly delivers all kinds of content from data centers to various terminals. Among them, images are commonly distributed content on CDN. Especially when loading a page, it often involves access to a large number of image resources, and these image resources are usually stored on cloud servers and distributed through CDN. However, there are some problems with distribution through CDN. On the one hand, developers often tend to ignore the download of the image resource file, thereby consuming a large amount of CDN traffic. On the other hand, when users load a large number of images, a large amount of data traffic will be consumed, and repeated downloading of resources will cause problems such as slow page opening and unsmooth use. Summary of the invention

[0003] The embodiments of the present invention provide a method, device, equipment and medium for loading an image, so as to solve the problems in the prior art of high traffic consumption and low loading efficiency caused by repeated downloading of image resources.

[0004] A method for loading an image, comprising:

[0005] Intercepting a client's image loading request, determining the client's application type according to an access path in the image loading request, and determining a preset image proxy corresponding to the application type;

[0006] The preset image proxy detects and processes the image URL address in the image loading request, and determines whether the image URL address meets the preset modification requirement according to the detection and processing result;

[0007] When the image URL address meets the preset modification requirements, modify the image URL address to obtain the target URL address;

[0008] The target image in the target format is accessed according to the target URL address and sent to the client, so that the target image is loaded into the display page after being rendered by the client.

[0009] A picture loading device, comprising:

[0010] A request interception module, used to intercept a client's image loading request, determine the client's application type according to the access path in the image loading request, and determine a preset image proxy corresponding to the application type;

[0011] A logic judgment module, used to detect and process the image URL address in the image loading request through the preset image proxy, and determine whether the image URL address meets the preset modification requirements according to the detection and processing result;

[0012] An address modification module is used to modify the URL address of the picture to obtain a target URL address when the URL address of the picture meets the preset modification requirements;

[0013] The image loading module is used to access the target image in the target format according to the target URL address and send it to the client so that the target image is loaded into the display page after being rendered by the client.

[0014] A computer device comprises a memory, a controller and a computer program stored in the memory and executable on the controller, wherein the controller is used to execute the above-mentioned image loading method.

[0015] A computer-readable storage medium stores a computer program, and the computer program implements the above-mentioned image loading method when executed by a processor.

[0016] The above-mentioned image loading method, device, equipment and medium, the image loading method of the present invention includes intercepting the client's image loading request, determining the application type of the client according to the access path in the image loading request, and determining a preset image proxy corresponding to the application type; detecting and processing the image URL address in the image loading request through the preset image proxy, and judging whether the image URL address meets the preset modification requirements according to the detection and processing results; when the image URL address meets the preset modification requirements, modifying the image URL address to obtain the target URL address; accessing the target image in the target format according to the target URL address, and sending it to the client, so as to load it into the display page after the client renders the target image.

[0017] The present invention intercepts the client's image loading request, detects and processes the image URL address in the image loading request, realizes the judgment of modifying the image URL address, thereby realizing the acquisition of the target image in the target format, and then realizes loading the target image in the target format into the display page of the client. Furthermore, by adopting the target format image, the image size is reduced, the bandwidth cost is saved, the request response speed is increased, and the efficiency of image loading is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0018] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings required for use in the description of the embodiments of the present invention will be briefly introduced below. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other accompanying drawings can be obtained based on these accompanying drawings without paying creative labor.

[0019] Figure 1 is a flow chart of a method for loading an image in one embodiment of the present invention;

[0020] Figure 2 is a flow chart of step S20 of the image loading method in one embodiment of the present invention;

[0021] Figure 3 is a flow chart of step S40 of the image loading method in one embodiment of the present invention;

[0022] Figure 4 is a flow chart of step S401 of the image loading method in one embodiment of the present invention;

[0023] Figure 5 is a flowchart of step S402 of the image loading method in one embodiment of the present invention;

[0024] Figure 6 is a flow chart of a method for loading a picture in another embodiment of the present invention;

[0025] Figure 7 is a flowchart of a method for loading a picture in yet another embodiment of the present invention;

[0026] Figure 8 This is a principle block diagram of a picture loading device in one embodiment of the present invention;

[0027] Fig. 9 is a schematic diagram of a computer device in one embodiment of the present invention. DETAILED DESCRIPTION

[0028] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are 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.

[0029] In one embodiment, if Figure 1 As shown, a method for loading an image is provided, comprising the following steps:

[0030] S10: intercepting a picture loading request from a client, determining an application type of the client according to an access path in the picture loading request, and determining a preset picture proxy corresponding to the application type.

[0031] Understandably, an image loading request refers to an HTTP request sent to a server when a page loads or displays an image in a web application or mobile application. The purpose of this request is to obtain the image data from the server. The client can be a mobile terminal or a PC terminal. Application types refer to types such as app native (i.e. native application), webview (the core view class in the WebKit framework, used to embed and manage web content in applications), or weex framework (a cross-platform mobile development framework for building high-performance, scalable mobile applications using front-end frameworks). The preset image proxy refers to the gildemodule image proxy corresponding to app native (Glide is configured as an image proxy mechanism through Module), the shouldInterceptRequest image proxy corresponding to webview (used to intercept and process before WebView loads resources), and the wximgloaderadapter image proxy corresponding to weex (a customized image loading module in the mechanism provided by Weex to proxy the behavior of image loading).

[0032] Specifically, the client's image loading request is intercepted through the API interface callback method. Then, the intercepted image loading request is parsed to obtain the access path and image URL address included in the image loading request. Through the reverse tracing of the access path, the application type of the client that initiated the image loading request is determined. Next, the preset proxy mapping relationship is obtained, and the preset image proxy corresponding to the application type is queried according to the proxy mapping relationship, and the preset image proxy is obtained from the server. Among them, the API interface Application Programming Interface, referred to as: API) refers to the application programming interface. For example, webview can obtain the URL address (Uniform Resource Locator) of the image being accessed by the display page through the API callback method shouldInterceptRequest, and intercept it. The API is defined as follows: the parameter contains the URL address of the access image resource, and then the judgment is made based on the URL address, and a new URL address WebResourceResponse is encapsulated and returned to the webview.

[0033] S20: Detecting and processing the image URL address in the image loading request through the preset image proxy, and judging whether the image URL address meets the preset modification requirement according to the detection and processing result.

[0034] Understandably, the image URL address is used to point to the location of a certain image resource in the server. The detection processing result is used to indicate whether the suffix format and host (i.e., the part of the URL used to identify the host name or IP address of the server where the resource is located) in the image URL address need to be modified. The preset modification requirement refers to the standard for modifying the URL address set in advance.

[0035] Specifically, after obtaining the preset image proxy, the image URL address in the image loading request is detected and processed by the preset image proxy, that is, the host and suffix in the image URL address are identified by the preset image proxy to obtain the host and suffix of the URL, and then, the host and suffix of the URL are detected and processed according to the preset rules to obtain the detection and processing result. Next, it is determined whether the image URL address meets the preset modification requirements based on the detection and processing result, wherein when the detection and processing result includes the address modification result and the format modification result, it is determined that the image URL address meets the preset modification requirements. When the detection and processing result does not include the address modification result and / or the format modification result, it is determined that the image URL address does not meet the preset modification requirements.

[0036] S30: When the picture URL address meets the preset modification requirement, modify the picture URL address to obtain the target URL address.

[0037] Understandably, the target URL address refers to the address of the image file after the host and suffix in the image URL address are modified.

[0038] Specifically, when the image URL address meets the preset modification requirements, that is, when the detection processing result includes the address modification result and the format modification result, the image URL address is subjected to suffix extraction to obtain the suffix in the image URL address. Then, the address of the extracted image URL address is modified according to the preset modification rules, that is, the image URL address is modified to the URL address of the image in the target format, thereby obtaining the target URL address. For example, the access of ".com / map / img.jpg" is changed to the access of ".com / map / img.jpg.webp", or the access of ".com / map / img.png" is changed to the access of ".com / map / img.png.webp".

[0039] S40: Obtain a target image in a target format according to the target URL address, and send it to the client, so that the target image is rendered on the client and loaded into the display page.

[0040] Understandably, the target format refers to the webp format, and the target image refers to the image to be loaded in the webp format.

[0041] Specifically, after obtaining the target URL address, the target URL address is parsed to determine the server address pointed to by the target URL address, an access request is initiated to the server address, and after receiving the server's response, a target image in the webp format is searched in the server corresponding to the server address to obtain the target image in the target format. Then, the target image in the target format is sent to the client to render the target image through the client's browser kernel, and the rendered target image is loaded into the corresponding position in the display page.

[0042] In the image loading method of the present invention, by intercepting the image loading request of the client, the image URL address in the image loading request is detected and processed, and the judgment of modifying the image URL address is realized, thereby realizing the acquisition of the target image in the target format, and then realizing the loading of the target image in the target format into the display page of the client. Furthermore, by adopting the image in the target format, the image size is reduced, the bandwidth cost is saved, the speed of request response is increased, and the efficiency of image loading is improved.

[0043] In one embodiment, in step S20, judging whether the image URL address meets the preset modification requirement according to the detection processing result includes:

[0044] S201, when the detection processing result includes an address modification result and a format modification result, determining that the image URL address meets a preset modification requirement.

[0045] S202: When the detection processing result does not include an address modification result and / or a format modification result, it is determined that the image URL address does not meet a preset modification requirement.

[0046] Understandably, the address modification result is used to indicate that the host of the URL address needs to be modified. The format modification result is used to indicate that the suffix format of the URL address (the format of the accessed image) needs to be modified.

[0047] Specifically, the detection processing result is parsed, and when the parsed detection processing result includes the address modification result and the format modification result, it is determined that the preset modification requirement is true, thereby determining that the image URL address meets the preset modification requirement. When the parsed detection processing result does not include the address modification result and / or the format modification result, it is determined that the preset modification requirement is false, thereby determining that the image URL address does not meet the preset modification requirement. For example, "extension" indicates that the format of the loaded image needs to be changed to the format of the ".webp" suffix, and "hostList" indicates that the host of the loaded image URL needs to be changed to the host of the URL in the ".webp" format. When the detection processing result includes both "hostList" and "extension", it is determined that "enable" is true, thereby confirming that the image URL address meets the preset modification requirement. When the detection processing result does not include "hostList" and / or "extension", it is determined that "enable" is false, thereby confirming that the image URL address does not meet the preset modification requirement. That is, in this embodiment, by parsing the detection processing result, when the detection processing result includes the address modification result and the format modification result, it is achieved to determine that the image URL address meets the preset modification requirement. When the detection processing result does not include the address modification result and / or the format modification result, it is determined that the image URL address does not meet the preset modification requirements.

[0048] In one embodiment, the step S40, that is, obtaining a target image in a target format by accessing the target URL address, includes:

[0049] S401, accessing the memory of the CDN server according to the target URL address to obtain a target image, and when it is detected according to the target URL address that the target image does not exist in the memory of the CDN server, detecting whether the target image exists in the disk of the CDN server.

[0050] S402, when the target image does not exist in the disk of the CDN server, obtain the original URL address corresponding to the target image, download the original data of the image from the network side based on the original URL address, perform data analysis on the original data of the image to obtain the target image in the target format, and save the target image to the memory and / or disk of the CDN server.

[0051] Understandably, the original URL address refers to the URL address of the network side image. The original image data refers to the binary image data stored on the network side. The network side refers to the network part connected to the CDN server.

[0052] Specifically, after obtaining the target URL address, the memory of the CDN server is first accessed through the target URL address, that is, the target image is detected on the memory of the CDN server through the target URL address, so as to determine whether the target image exists in the memory of the CDN server. When it is detected that the target image exists in the memory of the CDN server, the target image is loaded from the memory of the CDN server. Furthermore, when it is detected that the target image does not exist in the memory of the CDN server according to the target URL address, the target image is detected on the disk of the CDN server, so as to determine whether the target image exists in the disk of the CDN server. When the target image exists in the disk of the CDN server, the target image is cached in the memory of the CDN server, and the target image is loaded from the disk of the CDN server. Next, when the target image does not exist in the disk of the CDN server, the original URL address corresponding to the target image is obtained, and then the network side is accessed through the original URL address, and the original data of the image is downloaded on the network side, the original data of the image is parsed and format converted through the image conversion script, so as to obtain the target image in the target format, and the target image is saved in the memory and / or disk of the CDN server. That is, in this embodiment, the memory and / or disk of the CDN server are detected in sequence according to the target URL address, and when the target image exists in the memory or disk, the target image is loaded. When the target image does not exist in the memory and / or disk, the target image is loaded by accessing the network side, avoiding the inability to load the image in the client's page.

[0053] In one embodiment, the step S401 further includes:

[0054] S4011, perform a remaining space detection on the memory and disk of the CDN server to obtain a space detection result.

[0055] S4012, when the space detection result indicates that there is no remaining space in the memory and / or disk of the CDN server, a preset deletion strategy is executed on the memory and / or disk of the CDN server with no remaining space, and the preset deletion strategy includes: obtaining the access time of each cached image in the memory and / or disk with no remaining space, and comparing all the access times, and deleting the image with the earliest access time; the cached images include target images and original images.

[0056] Understandably, the space detection result refers to whether there is space in the memory and / or disk for caching pictures. The preset deletion strategy refers to the LRU strategy. The core idea of ​​the LRU (Least Recently Used) strategy is that the data has not been accessed in the recent period of time, and the probability of accessing it again in the future is also low. When the cache reaches the maximum capacity, the data that has not been accessed for the longest time is deleted. Or the LFU (Least Frequently Used) strategy is adopted, the core idea of ​​which is to decide to eliminate data items based on the access frequency of data items in the cache. The cached pictures include target pictures and original pictures, which refer to pictures stored in advance.

[0057] Specifically, the remaining space in the memory and disk of the CDN server is detected, that is, the space in the memory and / or disk of the CDN server is detected regularly (such as after each access or at fixed time intervals), so as to obtain a space detection result that represents the remaining space. When the space detection result indicates that there is remaining space in the memory and / or disk of the CDN server, the target image and the original image continue to be stored. When the space detection result indicates that there is no remaining space in the memory and / or disk of the CDN server, the access time of each cached image in the memory and / or disk with no remaining space is obtained, that is, the access time of all target images and the access time of all original images are obtained, and then the access time between all target images and the access time between all original images are compared, and the image with the earliest access time is deleted.

[0058] In another embodiment, a monitoring plug-in is set in the memory and / or disk of the CDN server to monitor the memory and / or disk space of the CDN server. When there is no remaining space in the memory and / or disk of the CDN server, a signal is triggered to execute a preset deletion strategy to delete the cached images in the memory and / or disk of the CDN server. The LFU (Least Frequently Used) strategy can be used to delete the cached images.

[0059] In this embodiment, by detecting the remaining space in the memory and disk of the CDN server, the space detection result is obtained, and then the preset deletion strategy is executed when there is no remaining space in the memory and / or disk of the CDN server, thereby realizing the deletion of cached images in the CDN server.

[0060] In one embodiment, the step S402, that is, downloading the original image data from the network side based on the original URL address, includes:

[0061] S4021, obtain the domain name contained in the original URL address, and determine whether the domain name is recorded locally.

[0062] S4022: If the domain name is recorded locally, the server IP address corresponding to the domain name is obtained according to a preset mapping relationship, and the target server is accessed through the server IP address to download the original image data.

[0063] S4023: If the domain name is not recorded locally, the domain name is sent to the DNS server for resolution, the server IP address corresponding to the domain name is determined according to the resolution result, and the target server is accessed through the server IP address to download the original image data.

[0064] Understandably, a domain name refers to the name of a computer or computer group consisting of a string of names separated by dots, which is used to identify the IP address of the computer during data transmission. The server IP address refers to the network address assigned to the server, which is used to uniquely identify and locate the server on the Internet. The DNS server is a server that converts domain names and their corresponding IP addresses. The preset mapping relationship refers to the mapping relationship between the domain name and the server IP address. The target server refers to the server corresponding to the server IP address.

[0065] Specifically, after obtaining the original URL address, the original URL address is parsed, that is, the domain name in the original URL address is identified by the domain name naming rule, so as to obtain the domain name contained in the original URL address. Then, it is detected whether the domain name is recorded in the local memory and / or disk, that is, the domain name is matched with the domain name stored in the local memory and / or disk. When the domain name is recorded locally, a preset mapping relationship is obtained, and the server IP address corresponding to the domain name is obtained through the preset mapping relationship. Then, the corresponding target server is accessed through the server IP address to download the original image data from the target server. Further, when the domain name is not recorded locally, the domain name is sent to the DNS server for DNS resolution, that is, the server IP address corresponding to the domain name is first queried in the cache of the DNS server. If there is no server IP address corresponding to the domain name in the cache, a query request is initiated to the DNS server of the Internet Service Provider (ISP), and the root domain name server will instruct the DNS resolver to request the top-level domain name server, and finally obtain the server IP address corresponding to the domain name, so as to obtain the resolution result. Then, the target server is accessed through the server IP address in the resolution result, and the original image data is downloaded from the target server. That is, in this embodiment, the domain name is obtained by parsing the original URL address. By determining whether the domain name is recorded locally, the server IP address is obtained through a preset mapping relationship, and the server IP address is determined through a DNS server, thereby downloading the original data of the image, thereby avoiding the inability to load the image in the page.

[0066] In one embodiment, after step S20, that is, after judging whether the image URL address meets the preset modification requirement according to the detection processing result, the following further includes:

[0067] S50, when the image URL address does not meet the preset modification requirements, access the memory of the CDN server according to the image URL address to obtain the original image. If it is detected that the original image does not exist in the memory of the CDN server according to the image URL address, check whether the original image exists in the disk of the CDN server.

[0068] S60, when the original image does not exist in the disk of the CDN server, obtain the original URL address corresponding to the original image, download the original data of the image from the network side based on the original URL address, perform data analysis on the original data of the image, and obtain the original image in the original format.

[0069] S70, saving the original image to the memory and / or disk of the CDN server, and sending it to the client, so that the client renders the original image and loads it into the display page.

[0070] Specifically, when the image URL address does not meet the preset modification requirements, that is, when the detection processing result does not include the address modification result and / or the format modification result, the memory of the CDN server is first accessed through the target URL address, that is, the original image detection is performed on the memory of the CDN server through the image URL address, so as to determine whether there is an original image in the memory of the CDN server. When it is detected that there is an original image in the memory of the CDN server, the original image in the original format is loaded from the memory of the CDN server. Furthermore, when it is detected that there is no original image in the memory of the CDN server according to the image URL address, the original image detection is performed on the disk of the CDN server, so as to determine whether there is an original image in the disk of the CDN server. When there is an original image in the disk of the CDN server, the original image is cached in the memory of the CDN server, and the original image is loaded from the disk of the CDN server. Further, when there is no original image in the disk of the CDN server, the original URL address corresponding to the original image is obtained, and then the network side is accessed through the original URL address, and the original data of the image is downloaded from the network side. Next, the original data of the image is parsed to obtain the original image in the original format, and the original image is saved in the memory and / or disk of the CDN server, and sent to the client, so that the original image is rendered through the browser kernel of the client, and the rendered original image is loaded into the display page of the client. That is, in this embodiment, when the image URL address does not meet the preset modification requirements, the memory and / or disk of the CDN server are detected in turn according to the image URL address, so that when the target image exists in the memory or disk, the target image is loaded. When the target image does not exist in the memory and disk, the target image is loaded by accessing the network side, avoiding the inability to load the image in the client's page.

[0071] In one embodiment, before step S40, that is, before obtaining the target image in the target format by accessing the target URL address, the process further includes:

[0072] S80, obtaining all original pictures from a file server, performing format conversion on all the original pictures through a picture conversion script, and obtaining target pictures corresponding to the original pictures.

[0073] S90: Send all the target images and all the original images to a CDN server, and store them in a memory and / or a disk of the CDN server.

[0074] Understandably, the file server refers to a server for storing original format images, such as a cloud server. The original format refers to image formats such as png, jpg, jpeg, and gif. The target format refers to the webp format. The target image refers to the image to be loaded in the webp format. The original image refers to the image to be loaded in the original format.

[0075] Specifically, before obtaining the target image of the target format according to the target URL address, all the original images of the original format in the file server are read, and then a preset image conversion script is obtained, and the format conversion of all the original images is performed by the image conversion script, that is, the original images of the original format are converted into the target image of the target format by the image conversion script, so as to obtain the target image corresponding to each original image. For example, an original image of "img.jpg" is obtained from the file server, and the original image of "img.jpg" is converted into the target image of "img.jpg.webp" by the image conversion script. Further, after all the original images are converted, all the target images and all the original images are sent to the CDN server and stored in the memory and / or disk of the CDN server. That is, in this embodiment, the format conversion of all the original images is performed by the image conversion script, the format conversion of the image is realized, the size of the image is reduced, and the acquisition of the target image is realized. By storing the target image and the original image in the CDN server, it is avoided that the image cannot be loaded when the target image fails to load.

[0076] It should be understood that the order of execution of the steps in the above embodiment does not necessarily mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiment of the present invention.

[0077] In one embodiment, a picture loading device is provided, which corresponds one-to-one to the picture loading method in the above embodiment. Figure 8 As shown, the image loading device includes a request interception module 10, a logic judgment module 20, an address modification module 30 and an image loading module 40. The functional modules are described in detail as follows:

[0078] The request interception module 10 is used to intercept the client's image loading request, determine the application type of the client according to the access path in the image loading request, and determine the preset image proxy corresponding to the application type;

[0079] The logic judgment module 20 is used to detect the image URL address in the image loading request through the preset image proxy, and determine whether the image URL address meets the preset modification requirement according to the detection result;

[0080] An address modification module 30 is used to modify the URL address of the picture to obtain a target URL address when the URL address of the picture meets a preset modification requirement;

[0081] The image loading module 40 is used to access the target image in the target format according to the target URL address and send it to the client so that the target image is loaded into the display page after being rendered by the client.

[0082] Optionally, the logic judgment module 20 includes:

[0083] A satisfying unit, configured to determine that the image URL address satisfies a preset modification requirement when the detection processing result includes an address modification result and a format modification result;

[0084] The unsatisfied unit is used to determine that the image URL address does not meet the preset modification requirements when the detection processing result does not include the address modification result and / or the format modification result.

[0085] Optionally, the picture loading module 40 includes:

[0086] a disk detection unit, configured to detect whether the target image exists in the disk of the CDN server when it is detected according to the target URL address that the target image does not exist in the memory of the CDN server;

[0087] A data parsing unit is used to obtain the original URL address corresponding to the target image when the target image does not exist in the disk of the CDN server, download the original data of the image from the network side based on the original URL address, perform data parsing on the original data of the image to obtain the target image in the target format, and save the target image to the memory and / or disk of the CDN server.

[0088] Optionally, the device further comprises:

[0089] The original detection image module is used to detect whether the original image exists in the disk of the CDN server when the image URL address does not meet the preset modification requirements and if it is detected according to the image URL address that the original image does not exist in the memory of the CDN server;

[0090] A data parsing module, used for obtaining an original URL address corresponding to the original image when the original image does not exist in the disk of the CDN server, downloading the original image data from the network side based on the original URL address, and performing data parsing on the original image data to obtain the original image in the original format;

[0091] The image saving module is used to save the original image to the memory and / or disk of the CDN server and send it to the client so that the original image is loaded into the display page after being rendered by the client.

[0092] Optionally, the data parsing unit includes:

[0093] A domain name subunit, used to obtain the domain name contained in the original URL address and determine whether the domain name is recorded locally;

[0094] A recording subunit, configured to obtain a server IP address corresponding to the domain name according to a preset mapping relationship if the domain name is recorded locally, and access a target server through the server IP address and download original image data;

[0095] The unrecorded subunit is used to send the domain name to the DNS server for resolution if the domain name is not recorded locally, determine the server IP address corresponding to the domain name according to the resolution result, access the target server through the server IP address and download the original data of the image.

[0096] Optionally, the device further comprises:

[0097] The remaining space detection unit is used to detect the remaining space of the memory and disk of the CDN server and obtain the space detection result;

[0098] The image deletion unit is used to execute a preset deletion strategy on the memory or / and disk of the CDN server with no remaining space when the space detection result indicates that there is no remaining space in the memory or / and disk of the CDN server. The preset deletion strategy includes: obtaining the access time of each cached image in the memory or / and disk with no remaining space, and comparing all the access times, and deleting the image with the earliest access time; the cached images include target images and original images.

[0099] Optionally, the device further comprises:

[0100] A format conversion module is used to obtain all original images from a file server, and to convert the formats of all the original images through an image conversion script to obtain target images corresponding to the original images;

[0101] The image storage module is used to send all the target images and all the original images to the CDN server and store them in the memory and / or disk of the CDN server.

[0102] This application further provides Fig. 9 A computer device is shown, comprising a memory, a controller, and a computer program stored in the memory and executable on the controller, wherein the controller is used to execute the picture loading method.

[0103] For the specific definition of the computer device, controller and its units and modules, please refer to the definition of the image loading method above, which will not be repeated here. Each module in the above controller can be implemented in whole or in part by software, hardware and a combination thereof. Understandably, the controller includes a processor, a memory, a network interface and a database connected by a device bus. Each module of the controller can be embedded in or independent of the processor in hardware form, or can be stored in the memory in software form, so that the processor can call and execute the operations corresponding to the above modules. Among them, the processor is used to provide computing and control capabilities. The memory includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating device, a computer program and a database. The internal memory provides an environment for the operation of the operating device and the computer program in the non-volatile storage medium. The database is used to store the data used by the image loading method in the above embodiment. The network interface is used to communicate with an external terminal through a network connection. When the computer program is executed by the processor, a method for loading an image is implemented.

[0104] In one embodiment, a computer-readable storage medium is provided, wherein the computer-readable storage medium stores a computer program, and the computer program implements the above-mentioned image loading method when executed by a processor.

[0105] Those skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to memory, storage, database or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory can include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM) or flash memory. Volatile memory can include random access memory (RAM) or external cache memory. As an illustration and not limitation, RAM is available in many forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), double data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link (Synchlink) DRAM (SLDRAM), memory bus (Rambus) direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).

[0106] Those skilled in the art can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example. In actual applications, the above-mentioned functions can be distributed and completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above.

[0107] The embodiments described above are only used to illustrate the technical solutions of the present invention, rather than to limit the same. Although the present invention has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention, and should all be included in the protection scope of the present invention.

Claims

1. A method for loading an image, characterized in that: include: Intercepting a client's image loading request, determining the client's application type according to an access path in the image loading request, and determining a preset image proxy corresponding to the application type; The preset image proxy detects and processes the image URL address in the image loading request, and determines whether the image URL address meets the preset modification requirement according to the detection and processing result; When the image URL address meets the preset modification requirements, modify the image URL address to obtain the target URL address; The target image in the target format is accessed according to the target URL address and sent to the client, so that the target image is loaded into the display page after being rendered by the client.

2. The image loading method according to claim 1, characterized in that: The determining, based on the detection processing result, whether the image URL address meets the preset modification requirement includes: When the detection processing result includes an address modification result and a format modification result, determining that the image URL address meets the preset modification requirement; When the detection processing result does not include an address modification result and / or a format modification result, it is determined that the picture URL address does not meet the preset modification requirement.

3. The image loading method according to claim 1, characterized in that: The step of accessing and obtaining a target image in a target format according to the target URL address includes: Accessing the memory of the CDN server according to the target URL address to obtain the target image, and when detecting that the target image does not exist in the memory of the CDN server according to the target URL address, detecting whether the target image exists in the disk of the CDN server; When the target image does not exist in the disk of the CDN server, the original URL address corresponding to the target image is obtained, the original data of the image is downloaded from the network side based on the original URL address, the original data of the image is parsed to obtain the target image in the target format, and the target image is saved to the memory and / or disk of the CDN server.

4. The image loading method according to claim 1, characterized in that: After judging whether the image URL address meets the preset modification requirement according to the detection processing result, the method further includes: When the image URL address does not meet the preset modification requirements, access the memory of the CDN server according to the image URL address to obtain the original image, and if it is detected according to the image URL address that the original image does not exist in the memory of the CDN server, detect whether the original image exists in the disk of the CDN server; When the original image does not exist in the disk of the CDN server, an original URL address corresponding to the original image is obtained, original image data is downloaded from the network side based on the original URL address, and data is parsed on the original image data to obtain the original image in the original format; The original image is saved in the memory and / or disk of the CDN server and sent to the client so that it is loaded into the display page after the client renders the original image.

5. The image loading method according to claim 3 or 4, characterized in that: The downloading of the original image data from the network side based on the original URL address includes: Obtain the domain name contained in the original URL address, and determine whether the domain name is recorded locally; If the domain name is recorded locally, the server IP address corresponding to the domain name is obtained according to the preset mapping relationship, and the target server is accessed through the server IP address to download the original image data; If the domain name is not recorded locally, the domain name is sent to the DNS server for resolution, the server IP address corresponding to the domain name is determined according to the resolution result, and the target server is accessed through the server IP address to download the original image data.

6. The image loading method according to claim 3 or 4, characterized in that: The image loading method further includes: Perform a remaining space check on the memory and disk of the CDN server to obtain the space check result; When the space detection result indicates that there is no remaining space in the memory and / or disk of the CDN server, a preset deletion strategy is executed on the memory and / or disk of the CDN server with no remaining space, and the preset deletion strategy includes: obtaining the access time of each cached image in the memory and / or disk with no remaining space, and comparing all the access times, and deleting the image with the earliest access time; the cached images include target images and original images.

7. The image loading method according to claim 1, characterized in that: Before obtaining the target image in the target format according to the target URL address, the method includes: Obtain all original images from the file server, convert the formats of all the original images through an image conversion script, and obtain target images corresponding to the original images; All the target images and all the original images are sent to the CDN server and stored in the memory and / or disk of the CDN server.

8. A picture loading device, characterized in that: include: A request interception module, used to intercept a client's image loading request, determine the client's application type according to the access path in the image loading request, and determine a preset image proxy corresponding to the application type; A logic judgment module, used to detect and process the image URL address in the image loading request through the preset image proxy, and determine whether the image URL address meets the preset modification requirements according to the detection and processing result; An address modification module is used to modify the URL address of the picture to obtain a target URL address when the URL address of the picture meets the preset modification requirements; The image loading module is used to access the target image in the target format according to the target URL address and send it to the client so that the target image is loaded into the display page after being rendered by the client.

9. A computer device, characterized in that: The method comprises a memory, a controller and a computer program stored in the memory and executable on the controller, wherein the controller is used to execute the image loading method according to any one of claims 1 to 7.

10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the image loading method according to any one of claims 1 to 7 is implemented.