[go: up one dir, main page]

CN110020320A - The method and apparatus for caching page pictures - Google Patents

The method and apparatus for caching page pictures Download PDF

Info

Publication number
CN110020320A
CN110020320A CN201711477761.6A CN201711477761A CN110020320A CN 110020320 A CN110020320 A CN 110020320A CN 201711477761 A CN201711477761 A CN 201711477761A CN 110020320 A CN110020320 A CN 110020320A
Authority
CN
China
Prior art keywords
picture
page
equipment
pixel ratio
display equipment
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN201711477761.6A
Other languages
Chinese (zh)
Inventor
李非凡
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Original Assignee
Beijing Jingdong Century Trading Co Ltd
Beijing Jingdong Shangke Information Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Beijing Jingdong Century Trading Co Ltd, Beijing Jingdong Shangke Information Technology Co Ltd filed Critical Beijing Jingdong Century Trading Co Ltd
Priority to CN201711477761.6A priority Critical patent/CN110020320A/en
Publication of CN110020320A publication Critical patent/CN110020320A/en
Pending legal-status Critical Current

Links

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F16/00Information retrieval; Database structures therefor; File system structures therefor
    • G06F16/90Details of database functions independent of the retrieved data types
    • G06F16/95Retrieval from the web
    • G06F16/957Browsing optimisation, e.g. caching or content distillation
    • G06F16/9574Browsing optimisation, e.g. caching or content distillation of access to content, e.g. by caching

Landscapes

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

Abstract

The invention discloses a kind of method and apparatus for caching page pictures, are related to field of computer technology.One specific embodiment of this method includes: the device pixel ratio for obtaining display equipment;When for the load of display equipment or refresh page, the picture address selection carried according to the page is loaded with the device pixel of display equipment than corresponding page pictures, and page pictures are cached to the local cache of display equipment.The embodiment can cache the page pictures of different picture versions for the display equipment of distinct device pixel ratio;And the page pictures of caching can be compatible with different browsers.

Description

Method and device for caching page pictures
Technical Field
The invention relates to the technical field of computers, in particular to a method and a device for caching page pictures.
Background
With the development of computer technology, more and more people start browsing contents such as page pictures or web pages including page pictures on display devices such as mobile phones, tablet phones or personal terminals. Different display devices have different screen pixel densities, and the different screen pixel densities cause the display devices to have different device pixel ratios; and the same page picture needs to display different resolutions in different display devices, the higher the resolution of the page picture is, the higher the definition of the page picture is, the larger the network flow consumed during loading the page picture is, and the slower the loading speed is.
In order to improve the speed of loading page pictures for the display equipment; and saving network flow for the user under the condition of ensuring the definition of the page picture, improving the use experience of the user and saving the network flow of the user, and caching the page picture in the local cache of the display equipment by using certain technology and strategy, wherein the existing cache scheme mainly comprises the following two types:
1. caching page pictures by using an Application Cache (Application Cache) technology of a fifth generation hypertext markup language (HTML 5);
2. and caching the page pictures by using a browser self-caching mechanism.
In the process of implementing the invention, the inventor finds that at least the following problems exist in the prior art:
the Application Cache technology cannot Cache page pictures of different picture versions for display equipment with different equipment pixel ratios;
2. different browsers in the same display device have different caching mechanisms, and the page pictures cached in the local cache of the display device cannot be maintained or updated in a unified manner.
Disclosure of Invention
In view of this, embodiments of the present invention provide a method and an apparatus for caching page pictures, which can cache page pictures of different picture versions for display devices with different device pixel ratios; and uniformly maintaining or updating the cached page pictures in the local cache of the display equipment.
To achieve the above object, according to an aspect of the embodiments of the present invention, a method for caching page pictures is provided.
The method for caching the page picture comprises the following steps: acquiring a device pixel ratio of the display device; when a page is loaded or refreshed for a display device, a page picture corresponding to the device pixel ratio of the display device is selected to be loaded according to a picture address carried by the page, and the page picture is cached to a local cache of the display device.
Optionally, before selecting a page picture corresponding to the device pixel ratio of the display device according to the picture address carried by the page and loading the page picture, the method further includes: judging whether the page picture is cached in a local cache of the display equipment or not; and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment to load.
Optionally, the picture address is obtained from a page tag of the page picture in the page; and selecting a page picture corresponding to the device pixel ratio of the display device to load according to the picture address carried by the page comprises: selecting the page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address to load; the page pictures of a plurality of picture versions and the mapping relation between each picture version of the page pictures and the pixel ratio of equipment are stored in the picture library corresponding to the picture addresses.
Optionally, caching the page picture to a local cache of the display device includes: acquiring the size of the page picture, and creating a canvas with the same size as the page picture; acquiring a context object of the page picture, and drawing the page picture on the canvas based on the context object; converting the page picture into a picture character string by using the canvas; generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture; and caching the storage character string to a local cache of the display equipment.
To achieve the above object, according to another aspect of the embodiments of the present invention, an apparatus for caching page pictures is provided.
The device for caching the page picture comprises the following steps: the acquisition module is used for acquiring the device pixel ratio of the display device; and the cache module is used for selecting a page picture corresponding to the equipment pixel ratio of the display equipment according to the picture address carried by the page for loading or refreshing the page for the display equipment, and caching the page picture to a local cache of the display equipment.
Optionally, the apparatus further comprises: the loading module is used for judging whether the page picture is cached in a local cache of the display equipment or not; and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment to load.
Optionally, the picture address is obtained from a page tag of the page picture in the page; and the cache module is further configured to: selecting the page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address to load; the page pictures of a plurality of picture versions and the mapping relation between each picture version of the page pictures and the pixel ratio of equipment are stored in the picture library corresponding to the picture addresses.
Optionally, the cache module is further configured to: acquiring the size of the page picture, and creating a canvas with the same size as the page picture; acquiring a context object of the page picture, and drawing the page picture on the canvas based on the context object; converting the page picture into a picture character string by using the canvas; generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture; and caching the storage character string to a local cache of the display equipment.
To achieve the above object, according to another aspect of the embodiments of the present invention, an electronic device for caching page pictures is provided.
The electronic equipment for caching the page picture comprises the following components: one or more processors; the storage device is used for storing one or more programs, and when the one or more programs are executed by the one or more processors, the one or more processors implement the method for caching the page pictures according to the embodiment of the invention.
To achieve the above object, according to still another aspect of embodiments of the present invention, there is provided a computer-readable storage medium.
A computer-readable storage medium of an embodiment of the present invention stores thereon a computer program, which when executed by a processor implements a method of caching page pictures of an embodiment of the present invention.
One embodiment of the above invention has the following advantages or benefits: when the page is loaded or refreshed for the display equipment, the page picture corresponding to the equipment pixel ratio is selected according to the equipment pixel ratio and the picture address of the display equipment to load the display equipment, and the page picture corresponding to the equipment pixel ratio of the display equipment is cached in a local cache of the display equipment, so that the problem that page pictures with different picture versions cannot be cached for the display equipment with different equipment pixel ratios is solved; the technical problem that the page pictures cached in the local cache of the display equipment cannot be maintained or updated in a unified manner is solved, and the page pictures of the picture versions corresponding to the equipment pixel ratio of the display equipment are cached for different display equipment; and the display equipment uses a uniform cache mechanism, and can perform uniform maintenance or update on the page pictures cached in the local cache of the display equipment.
Further effects of the above-mentioned non-conventional alternatives will be described below in connection with the embodiments.
Drawings
The drawings are included to provide a better understanding of the invention and are not to be construed as unduly limiting the invention. Wherein:
FIG. 1 is a diagram illustrating the main steps of a method for caching page pictures according to an embodiment of the present invention;
FIG. 2 is a diagram illustrating major blocks of an apparatus for caching page pictures according to an embodiment of the present invention;
FIG. 3 is an exemplary system architecture diagram in which embodiments of the present invention may be employed;
fig. 4 is a schematic block diagram of a computer system suitable for use in implementing a terminal device or server of an embodiment of the invention.
Detailed Description
Exemplary embodiments of the present invention are described below with reference to the accompanying drawings, in which various details of embodiments of the invention are included to assist understanding, and which are to be considered as merely exemplary. Accordingly, those of ordinary skill in the art will recognize that various changes and modifications of the embodiments described herein can be made without departing from the scope and spirit of the invention. Also, descriptions of well-known functions and constructions are omitted in the following description for clarity and conciseness.
It should be noted that the embodiments of the present invention and the technical features of the embodiments may be combined with each other without conflict.
Fig. 1 is a schematic diagram illustrating the main steps of a method for caching page pictures according to an embodiment of the present invention.
As shown in fig. 1, a method for caching page pictures according to an embodiment of the present invention mainly includes the following steps:
step S101: a device pixel ratio of the display device is obtained.
The display device is an internet terminal with a display function, such as a mobile phone, a tablet or a personal terminal. With the development of computer technology, more and more users use display devices to browse contents such as page pictures or web pages including page pictures. Generally, the same page picture needs page pictures with different resolutions in different display devices, the higher the resolution of the page picture is, the higher the definition of the page picture is, the larger the network traffic consumed during loading the page picture is, and the slower the loading speed is, the network traffic refers to the data volume transmitted on a network; also, different display devices have different screen pixel densities, which cause the display devices to have different device pixel ratios. The screen pixel density refers to the number of pixels of each inch of the screen, and the greater the pixel density, the richer the details of the displayed page picture are; the device pixel ratio is a ratio of a device physical pixel to a device independent pixel, and is used for describing a scaling degree of the whole rendering environment on a hardware device, namely the device pixel ratio can represent the definition of a picture displayed in the device.
In order to improve the use experience of a user and save network traffic for the user under the condition of ensuring the definition of a picture, the embodiment of the invention provides that a page picture of a corresponding picture version is selected for the user according to the device pixel ratio of the display device, namely the device pixel ratio of the display device used by the user is obtained before the picture is loaded, for example, the device pixel ratio of the display device can be obtained by using JavaScript. The JavaScript is a scripting language belonging to a Web, has been widely used for global wide area network (Web) application development, is often used to add various dynamic functions to a Web page, and provides a smoother and more beautiful browsing effect for a user, and the JavaScript script can implement its own function by being embedded in an HTML page.
In order to increase the speed of loading the page picture for the display device, the page picture loaded for the display device may be called from a local cache (localStorage) of the display device, that is, it is determined whether the page picture to be loaded exists in the localStorage of the display device, if the page picture is cached in the local cache of the display device and the feature of the page picture in the local cache meets the loading requirement, the page picture in the local cache of the display device is used for loading for the display device, where the loading requirement refers to that a device pixel ratio corresponding to the page picture corresponds to a device pixel ratio of the display device, the page picture is within a validity period, and the like, and whether the page picture is within the validity period may be determined based on a version number of the page picture or time information; otherwise, step S102 is executed, that is, the page picture is obtained according to the picture address. In this embodiment of the present invention, the method for caching page pictures may further include: judging whether a page picture is cached in a local cache of the display equipment or not; and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment for loading.
Step S102: when a page is loaded or refreshed for the display equipment, a page picture corresponding to the equipment pixel ratio of the display equipment is selected according to the picture address carried by the page for loading, and the page picture is cached to the local cache of the display equipment.
Because the page carries the picture addresses of all the page pictures of the page, when the display device loads or refreshes the page, the page picture suitable for the display device, namely the page picture corresponding to the device pixel ratio of the display device, can be selected based on the device pixel ratio of the display device according to the picture addresses of the stored page pictures, and the selected page picture is loaded for the display device.
In the embodiment of the invention, the picture address is obtained from the page tag of the page picture in the page; selecting a page picture corresponding to the device pixel ratio of the display device to load according to the picture address carried by the page can be realized by the following steps: and selecting a page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address for loading. The page picture browsed by the user or the content of the webpage comprising the page picture and the like is displayed in a page form, and the page picture in the page can record the picture address through the page tag, so that the picture address can be obtained through the page tag of the page picture, and the page picture corresponding to the equipment pixel ratio of the display equipment can be obtained.
It should be noted that the picture library corresponding to the picture address stores page pictures of multiple picture versions and mapping relationships between the picture versions of the page pictures and the pixel ratios of the devices. For different device pixel ratios, page pictures of picture versions corresponding to the different device pixel ratios can be obtained in advance, the page pictures of the different picture versions and the mapping relation between each picture version of the page pictures and the device pixel ratio are stored in a picture library corresponding to a picture address, and in addition, the mapping relation between each picture version of the page pictures and the device pixel ratio can be the mapping relation between the name of each picture version of the page pictures and the device pixel ratio or the mapping relation between the version number of each picture version of the page pictures and the device pixel ratio.
Generally, page pictures are transmitted or stored in the form of picture character strings, and when the page pictures are cached in a local cache of the display device, the page picture version number, the device pixel ratio of the display device, time information and the like can be recorded besides the picture character strings. In the embodiment of the present invention, caching the page picture to the local cache of the display device may be implemented by the following steps: acquiring the size of a page picture, and creating a canvas with the same size as the page picture; acquiring a context object of the page picture, and drawing the page picture on a canvas based on the context object; converting the page picture into a picture character string by using canvas; generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture; and caching the storage character string to a local cache of the display device.
A Canvas (Canvas API) is a tag for generating an image in a webpage in real time, and can be used for operating page picture content; the context object refers to features of the page picture in the webpage, such as a drawing target village, a drawing path, a drawing state and the like.
When loading the page picture for the display device, selecting the page picture through a local cache of the display device, or selecting the page picture according to a picture address corresponding to the page picture, and for the condition that the page picture is preferentially selected according to the picture address corresponding to the page picture, if the page picture already exists in the local cache of the display device, changing the version number of the page picture selected according to the picture address, and then caching the page picture to the local cache of the display device; the cached page pictures in the local cache of the display device can also be updated.
In addition, some existing browsers can cache page pictures through their own caching mechanisms, but different browsers have different caching mechanisms, so that several caching mechanisms exist in the same display device at the same time, and therefore, the page pictures cached in the local cache of the display device cannot be maintained or updated in a unified manner. The method for caching the page pictures can enable each browser of the display equipment to use a uniform caching mechanism, so that the page pictures cached in the local cache of the display equipment are uniformly maintained or updated.
According to the method for caching the page pictures, the page pictures corresponding to the device pixel ratio are selected to be loaded for the display device according to the device pixel ratio and the picture address of the display device when the page is loaded or refreshed for the display device, and the page pictures corresponding to the device pixel ratio of the display device are cached in the local cache of the display device, so that the problem that the page pictures of different picture versions cannot be cached for the display devices with different device pixel ratios is solved; the technical problem that the page pictures cached in the local cache of the display equipment cannot be maintained or updated in a unified manner is solved, and the page pictures of the picture versions corresponding to the equipment pixel ratio of the display equipment are cached for different display equipment; and the display equipment uses a uniform cache mechanism, and can perform uniform maintenance or update on the page pictures cached in the local cache of the display equipment.
Fig. 2 is a schematic diagram of main modules of an apparatus for caching page pictures according to an embodiment of the present invention.
As shown in fig. 2, an apparatus 200 for caching page pictures according to an embodiment of the present invention includes: an acquisition module 201 and a caching module 202.
Wherein,
an obtaining module 201, configured to obtain a device pixel ratio of the display device;
the caching module 202 is configured to, when a page is loaded or refreshed for a display device, select a page picture corresponding to a device pixel ratio of the display device according to a picture address carried by the page to load, and cache the page picture in a local cache of the display device.
Furthermore, the apparatus further comprises: the loading module is used for judging whether the page picture is cached in a local cache of the display equipment or not; and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment to load.
In the embodiment of the invention, the picture address is obtained from a page tag of the page picture in the page; and the caching module 202 is further configured to: selecting the page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address to load; the page pictures of a plurality of picture versions and the mapping relation between each picture version of the page pictures and the pixel ratio of equipment are stored in the picture library corresponding to the picture addresses.
In this embodiment of the present invention, the caching module 202 is further configured to: acquiring the size of the page picture, and creating a canvas with the same size as the page picture; acquiring a context object of the page picture, and drawing the page picture on the canvas based on the context object; converting the page picture into a picture character string by using the canvas; generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture; and caching the storage character string to a local cache of the display equipment.
According to the device for caching the page pictures, disclosed by the embodiment of the invention, when the page is loaded or refreshed for the display equipment, the page picture corresponding to the equipment pixel ratio is selected to be loaded for the display equipment according to the equipment pixel ratio and the picture address of the display equipment, and the page picture corresponding to the equipment pixel ratio of the display equipment is cached in the local cache of the display equipment, so that the problem that the page pictures with different picture versions cannot be cached for the display equipment with different equipment pixel ratios is overcome; the technical problem that the page pictures cached in the local cache of the display equipment cannot be maintained or updated in a unified manner is solved, and the page pictures of the picture versions corresponding to the equipment pixel ratio of the display equipment are cached for different display equipment; and the display equipment uses a uniform cache mechanism, and can perform uniform maintenance or update on the page pictures cached in the local cache of the display equipment.
To further illustrate the technical idea of the embodiment of the present invention, the technical solution of the embodiment of the present invention is now described with reference to specific application scenarios:
the page of pictures (IMG) tags are used to define images in hypertext markup language (HTML) pages, and the IMG tags have two necessary attributes: the src attribute is used to record an absolute path or a relative path of a stored picture, and the alt attribute provides information to replace the picture. In the embodiment of the invention, the picture address of the page picture can be recorded through the src attribute of the IMG tag of the page picture; the method comprises the steps that JavaScript can obtain each page picture based on the picture address of each page picture in a webpage when controlling the loading of the page picture of the webpage, in addition, a getContext () method of the JavaScript can be used for returning an environment for drawing on a Canvas API, a drawImage () method of the JavaScript can be used for drawing images, Canvas or videos on the Canvas API, and a todataURL () method of the JavaScript can convert the content of the current Canvas API into a Uniform Resource Locator (URL) format of a character (data) type.
It should be noted that, in order to enable different display devices to display a page picture most suitable for the display device when loading or refreshing a page, when a picture library corresponding to a picture address stores a certain page picture, the page pictures of multiple picture versions are stored at the same time, the page picture of each picture version corresponds to a device pixel ratio of one display device, and a mapping relationship between each picture version of the page picture of each picture version and each device pixel ratio is stored in the picture address. For example: page pictures of three picture versions are stored in a picture library corresponding to a picture address of a certain page picture, namely 100px page picture @1.png, 200px page picture @2.png and 300px page picture @3.png, and device pixel ratios corresponding to the three picture versions are 1, 2 and 3 respectively, during storage, in addition to storing the page pictures of the three picture versions, mapping relations between the picture versions of the page picture and the device pixel ratios are recorded, for example, the page picture @1 corresponds to the device pixel ratio 1, the page picture @2 corresponds to the device pixel ratio 2, and the page picture @3 corresponds to the device pixel ratio 3, wherein px means pixels; the portable network graphics (png) refers to a lossless compressed bitmap sheet format, in the above example, "page picture @ n.png" is used as the name of the page picture, where N may be the version number of the page picture, or the device pixel ratio corresponding to the page picture, and so on.
In the embodiment of the present invention, when the display device loads or refreshes the page, the device pixel ratio of the display device may be obtained through JavaScript, and the page picture corresponding to the device pixel ratio of the display device, which needs to be loaded in the page, may be obtained through the following two ways:
1. obtaining page pictures according to picture addresses
Firstly, acquiring page tags of all page pictures in a page, and respectively acquiring information such as picture addresses of all the page pictures and version numbers of the page pictures from all the page tags; meanwhile, acquiring a device pixel ratio of display equipment used by a user; then selecting a page picture corresponding to the equipment pixel ratio of the display equipment from a picture library corresponding to the picture address according to the equipment pixel ratio; and finally, loading the selected page picture for the display equipment. It should be noted that the page picture loaded for the display device, which is obtained according to the picture address, may be cached in a localStorage of the display device, specifically, the size of the page picture is obtained, and a Canvas API with the same size as the page picture is created; acquiring a context object of a page picture, and drawing the page picture on a Canvas API based on the context object, wherein the context object of the page picture can be acquired by using a getContext () method of JavaScript, and the page picture can be drawn on the Canvas API by using a drawImage method of JavaScript; converting the page picture into a picture character string by using a Canvas API, and converting the page picture into the picture character string by using a TODataURL method of the Canvas API; generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture; caching the storage character string to a localStorage of the display device;
2. obtaining page pictures from localStorage of display device
Firstly, acquiring page tags of all page pictures in a page, and respectively acquiring information such as version numbers of all page pictures from all page tags; meanwhile, acquiring a device pixel ratio of the display device; then, judging whether a page picture needing to be loaded exists in a localStorage of the display device, and searching in the localStorage by using a JavaScript code to determine whether the page picture needing to be loaded exists in the localStorage; if the page picture needing to be loaded exists in the localStorage, checking whether the characteristics of the page picture in the localStorage meet the loading requirement, namely checking whether a device pixel ratio corresponding to the page picture in the localStorage corresponds to a device pixel ratio of display equipment, and judging whether the page picture is in the validity period based on the version number of the page picture or the information of the page picture; and finally, if the page picture in the localStorage corresponds to the device pixel ratio of the display device and is within the validity period, loading the page picture in the localStorage for the display device, and otherwise, loading the page picture acquired according to the picture address for the display device.
The two manners of acquiring the page picture in the page may be selected according to actual situations, for example, acquiring the page picture only according to a picture address, or preferentially acquiring the page picture from a localStorage of the display device.
Fig. 3 illustrates an exemplary system architecture 300 of a method for caching page pictures or an apparatus for caching page pictures, to which an embodiment of the present invention may be applied.
As shown in fig. 3, the system architecture 300 may include terminal devices 301, 302, 303, a network 304, and a server 305. The network 304 serves as a medium for providing communication links between the terminal devices 301, 302, 303 and the server 305. Network 304 may include various connection types, such as wired, wireless communication links, or fiber optic cables, to name a few.
The user may use the terminal device 301, 302, 303 to interact with the server 305 via the network 304 to receive or send messages or the like. The terminal devices 301, 302, 303 may have various communication client applications installed thereon, such as shopping applications, web browser applications, search applications, instant messaging tools, mailbox clients, social platform software, and the like.
The terminal devices 301, 302, 303 may be various electronic devices having a display screen and supporting web browsing, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like.
The server 305 may be a server providing various services, such as a background management server providing support for shopping websites browsed by the user using the terminal devices 301, 302, 303. The background management server may analyze and perform other processing on the received data such as the product information query request, and feed back a processing result (e.g., target push information and product information) to the terminal device.
It should be noted that the method for caching page pictures provided by the embodiment of the present invention is generally executed by the server 305, and accordingly, the device for caching page pictures is generally disposed in the server 305.
It should be understood that the number of terminal devices, networks, and servers in fig. 3 is merely illustrative. There may be any number of terminal devices, networks, and servers, as desired for implementation.
Referring now to FIG. 4, a block diagram of a computer system 400 suitable for use with a terminal device implementing an embodiment of the invention is shown. The terminal device shown in fig. 4 is only an example, and should not bring any limitation to the functions and the scope of use of the embodiments of the present invention.
As shown in fig. 4, the computer system 400 includes a Central Processing Unit (CPU)401 that can perform various appropriate actions and processes in accordance with a program stored in a Read Only Memory (ROM)402 or a program loaded from a storage section 408 into a Random Access Memory (RAM) 403. In the RAM 403, various programs and data necessary for the operation of the system 400 are also stored. The CPU 401, ROM 402, and RAM 403 are connected to each other via a bus 404. An input/output (I/O) interface 405 is also connected to bus 404.
The following components are connected to the I/O interface 405: an input section 406 including a keyboard, a mouse, and the like; an output section 407 including a display device such as a Cathode Ray Tube (CRT), a Liquid Crystal Display (LCD), and the like, and a speaker; a storage section 408 including a hard disk and the like; and a communication section 409 including a network interface card such as a LAN card, a modem, or the like. The communication section 409 performs communication processing via a network such as the internet. A driver 410 is also connected to the I/O interface 405 as needed. A removable medium 411 such as a magnetic disk, an optical disk, a magneto-optical disk, a semiconductor memory, or the like is mounted on the drive 410 as necessary, so that a computer program read out therefrom is mounted into the storage section 408 as necessary.
In particular, according to the embodiments of the present disclosure, the processes described above with reference to the flowcharts may be implemented as computer software programs. For example, embodiments of the present disclosure include a computer program product comprising a computer program embodied on a computer readable medium, the computer program comprising program code for performing the method illustrated in the flow chart. In such an embodiment, the computer program may be downloaded and installed from a network through the communication section 409, and/or installed from the removable medium 411. The computer program performs the above-described functions defined in the system of the present invention when executed by a Central Processing Unit (CPU) 401.
It should be noted that the computer readable medium shown in the present invention can be a computer readable signal medium or a computer readable storage medium or any combination of the two. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, or device, or any combination of the foregoing. More specific examples of the computer readable storage medium may include, but are not limited to: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a Random Access Memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disc read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the present invention, a computer readable storage medium may be any tangible medium that can contain, or store a program for use by or in connection with an instruction execution system, apparatus, or device. In the present invention, however, a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in baseband or as part of a carrier wave. Such a propagated data signal may take many forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may also be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device. Program code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to: wireless, wire, fiber optic cable, RF, etc., or any suitable combination of the foregoing.
The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams or flowchart illustration, and combinations of blocks in the block diagrams or flowchart illustration, can be implemented by special purpose hardware-based systems which perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
The modules described in the embodiments of the present invention may be implemented by software or hardware. The described modules may also be provided in a processor, which may be described as: a processor includes an acquisition module and a cache module. The names of these modules do not in some cases constitute a limitation on the module itself, and for example, the acquisition module may also be described as a "module that acquires the device pixel ratio of the display device".
As another aspect, the present invention also provides a computer-readable medium that may be contained in the apparatus described in the above embodiments; or may be separate and not incorporated into the device. The computer readable medium carries one or more programs which, when executed by a device, cause the device to comprise: step S101: acquiring a device pixel ratio of a display device; step S102: when a page is loaded or refreshed for the display equipment, a page picture corresponding to the equipment pixel ratio of the display equipment is selected according to the picture address carried by the page for loading, and the page picture is cached to the local cache of the display equipment.
According to the technical scheme of the embodiment of the invention, when the page is loaded or refreshed for the display equipment, the page picture corresponding to the equipment pixel ratio is selected according to the equipment pixel ratio and the picture address of the display equipment to load the display equipment, and the page picture corresponding to the equipment pixel ratio of the display equipment is cached in the local cache of the display equipment, so that the problem that page pictures with different picture versions cannot be cached for the display equipment with different equipment pixel ratios is overcome; the technical problem that the page pictures cached in the local cache of the display equipment cannot be maintained or updated in a unified manner is solved, and the page pictures of the picture versions corresponding to the equipment pixel ratio of the display equipment are cached for different display equipment; and the display equipment uses a uniform cache mechanism, and can perform uniform maintenance or update on the page pictures cached in the local cache of the display equipment.
The above-described embodiments should not be construed as limiting the scope of the invention. Those skilled in the art will appreciate that various modifications, combinations, sub-combinations, and substitutions can occur, depending on design requirements and other factors. Any modification, equivalent replacement, and improvement made within the spirit and principle of the present invention should be included in the protection scope of the present invention.

Claims (10)

1.A method for caching page pictures, comprising:
acquiring a device pixel ratio of the display device;
when a page is loaded or refreshed for a display device, a page picture corresponding to the device pixel ratio of the display device is selected to be loaded according to a picture address carried by the page, and the page picture is cached to a local cache of the display device.
2. The method according to claim 1, wherein before selecting the page picture corresponding to the device pixel ratio of the display device according to the picture address carried by the page for loading, the method further comprises:
judging whether the page picture is cached in a local cache of the display equipment or not;
and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment to load.
3. The method of claim 1, wherein the picture address is obtained from a page tag of the page picture in the page; and
selecting a page picture corresponding to the device pixel ratio of the display device to load according to the picture address carried by the page comprises the following steps:
selecting the page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address to load; the page pictures of a plurality of picture versions and the mapping relation between each picture version of the page pictures and the pixel ratio of equipment are stored in the picture library corresponding to the picture addresses.
4. The method of claim 3, wherein caching the page picture to a local cache of the display device comprises:
acquiring the size of the page picture, and creating a canvas with the same size as the page picture;
acquiring a context object of the page picture, and drawing the page picture on the canvas based on the context object;
converting the page picture into a picture character string by using the canvas;
generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture;
and caching the storage character string to a local cache of the display equipment.
5. An apparatus for caching page pictures, comprising:
the acquisition module is used for acquiring the device pixel ratio of the display device;
and the cache module is used for selecting a page picture corresponding to the equipment pixel ratio of the display equipment according to the picture address carried by the page for loading or refreshing the page for the display equipment, and caching the page picture to a local cache of the display equipment.
6. The apparatus of claim 5, further comprising:
the loading module is used for judging whether the page picture is cached in a local cache of the display equipment or not; and when the page picture is cached in the local cache of the display equipment, the equipment pixel ratio corresponding to the page picture in the local cache of the display equipment is the same as the equipment pixel ratio of the display equipment, and the page picture in the local cache of the display equipment is in the validity period, calling the page picture in the local cache of the display equipment to load.
7. The apparatus of claim 5, wherein the picture address is obtained from a page tag of the page picture in the page; and
the cache module is further configured to:
selecting the page picture corresponding to the equipment pixel ratio of the display equipment from the picture library corresponding to the picture address to load; the page pictures of a plurality of picture versions and the mapping relation between each picture version of the page pictures and the pixel ratio of equipment are stored in the picture library corresponding to the picture addresses.
8. The apparatus of claim 7, wherein the caching module is further configured to:
acquiring the size of the page picture, and creating a canvas with the same size as the page picture;
acquiring a context object of the page picture, and drawing the page picture on the canvas based on the context object;
converting the page picture into a picture character string by using the canvas;
generating a storage character string based on the picture character string data, the device pixel ratio of the display device, the time information and the version number of the page picture;
and caching the storage character string to a local cache of the display equipment.
9. An electronic device for caching page pictures, comprising:
one or more processors;
a storage device for storing one or more programs,
when executed by the one or more processors, cause the one or more processors to implement the method of any one of claims 1-4.
10. A computer-readable medium, on which a computer program is stored, which, when being executed by a processor, carries out the method according to any one of claims 1-4.
CN201711477761.6A 2017-12-29 2017-12-29 The method and apparatus for caching page pictures Pending CN110020320A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN201711477761.6A CN110020320A (en) 2017-12-29 2017-12-29 The method and apparatus for caching page pictures

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN201711477761.6A CN110020320A (en) 2017-12-29 2017-12-29 The method and apparatus for caching page pictures

Publications (1)

Publication Number Publication Date
CN110020320A true CN110020320A (en) 2019-07-16

Family

ID=67187179

Family Applications (1)

Application Number Title Priority Date Filing Date
CN201711477761.6A Pending CN110020320A (en) 2017-12-29 2017-12-29 The method and apparatus for caching page pictures

Country Status (1)

Country Link
CN (1) CN110020320A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110647695A (en) * 2019-08-12 2020-01-03 深圳点猫科技有限公司 Method and device for converting webpage data into picture attachment
CN113676756A (en) * 2021-08-23 2021-11-19 北京字跳网络技术有限公司 Picture request method, device, equipment, storage medium and program product

Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013060185A1 (en) * 2011-10-27 2013-05-02 腾讯科技(深圳)有限公司 Method, apparatus and mobile device for viewing pictures in mobile phone browser
CN105302864A (en) * 2015-09-22 2016-02-03 努比亚技术有限公司 Picture loading apparatus and method according to screen resolution
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN106294663A (en) * 2016-08-04 2017-01-04 网宿科技股份有限公司 A kind of electronic equipment and application image processing method and system
CN107291519A (en) * 2017-08-09 2017-10-24 四川长虹电器股份有限公司 A kind of cross-platform image cache implementation method of webview based on mobile terminal

Patent Citations (5)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2013060185A1 (en) * 2011-10-27 2013-05-02 腾讯科技(深圳)有限公司 Method, apparatus and mobile device for viewing pictures in mobile phone browser
CN105302864A (en) * 2015-09-22 2016-02-03 努比亚技术有限公司 Picture loading apparatus and method according to screen resolution
CN106095835A (en) * 2016-05-31 2016-11-09 广东能龙教育股份有限公司 Client side picture four-layer caching method
CN106294663A (en) * 2016-08-04 2017-01-04 网宿科技股份有限公司 A kind of electronic equipment and application image processing method and system
CN107291519A (en) * 2017-08-09 2017-10-24 四川长虹电器股份有限公司 A kind of cross-platform image cache implementation method of webview based on mobile terminal

Non-Patent Citations (3)

* Cited by examiner, † Cited by third party
Title
唐胡鑫: "《网站运营与数据分析 双色版》", 31 December 2016, 航空工业出版社 *
潘兴华 等: "《电商实操疯狂讲义 淘宝、天猫、阿里巴巴开店+运营+推广+数据分析+客服培训》", 31 January 2016, 中国铁道出版社 *
陈万林: "《网页好设计!移动网站页面设计与效果整合实战开发 HTML5+CCS3+JQuery Mobile》", 30 November 2016, 中国铁道出版社 *

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN110647695A (en) * 2019-08-12 2020-01-03 深圳点猫科技有限公司 Method and device for converting webpage data into picture attachment
CN113676756A (en) * 2021-08-23 2021-11-19 北京字跳网络技术有限公司 Picture request method, device, equipment, storage medium and program product

Similar Documents

Publication Publication Date Title
CN110096660B (en) Method and device for loading page pictures and electronic equipment
CN107622135B (en) Method and apparatus for displaying information
AU2011101576B4 (en) Method and systems for generating and displaying a preview image of a content area
CN106575298B (en) Rapid presentation of web sites containing dynamic content and stale content
US9348939B2 (en) Web site sectioning for mobile web browser usability
CN106294658B (en) Webpage quick display method and device
US20090085921A1 (en) Populate Web-Based Content Based on Space Availability
CN110020329B (en) Method, device and system for generating webpage
CN110020304A (en) A kind of method and apparatus of loading page
CN110795649A (en) Target page display method, device and system and electronic equipment
JP7538948B2 (en) Image processing method and apparatus, and computer-readable storage medium
CN111294395A (en) Terminal page transmission method, device, medium and electronic equipment
CN107330087B (en) Page file generation method and device
CN111754600B (en) Poster image generation method and device and electronic equipment
US11438403B2 (en) Page presentation method and system, computer system, and computer readable medium
CN111581553B (en) Network image display method, system, electronic equipment and storage medium
CN113282852B (en) Method and device for editing web page
CN106354792B (en) Webpage display method and device
CN115495417A (en) Content loading method, device, equipment, medium and program product
CN110020320A (en) The method and apparatus for caching page pictures
CN115470432A (en) Page rendering method and device, electronic equipment and computer readable medium
US9336319B2 (en) Data file and rule driven synchronous or asynchronous document generation
CN104956360B (en) Presented using the progressive picture of data URI enhancings
CN113760438A (en) Page display method and device for webpage application
CN117390326A (en) Page management method, device, equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination
RJ01 Rejection of invention patent application after publication

Application publication date: 20190716

RJ01 Rejection of invention patent application after publication