CN108846141A - A kind of offline cache loading method and device - Google Patents
A kind of offline cache loading method and device Download PDFInfo
- Publication number
- CN108846141A CN108846141A CN201810760618.6A CN201810760618A CN108846141A CN 108846141 A CN108846141 A CN 108846141A CN 201810760618 A CN201810760618 A CN 201810760618A CN 108846141 A CN108846141 A CN 108846141A
- Authority
- CN
- China
- Prior art keywords
- resource
- memory
- internet resources
- request
- load request
- 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.)
- Granted
Links
Landscapes
- Information Transfer Between Computers (AREA)
Abstract
The present invention provides a kind of offline cache loading method and device, it is related to calculating equipment technical field.The offline cache loading method obtains the Internet resources load request of the uniform resource locator comprising corresponding resource first, the corresponding resource of the uniform resource locator is searched in memory, if not searching the resource in the memory, the resource is searched in external memory, if searching the resource in the external memory, the resource is loaded into the memory.The offline cache loading method realizes caching and caching of the resource in memory and external memory in iOS operating system and reads, and improves the utilization rate of caching, relieving system memory usage has effectively achieved the offline cache to Internet resources.
Description
Technical field
The present invention relates to equipment technical field is calculated, in particular to a kind of offline cache loading method and device.
Background technique
With the fast development of Internet technology, data and resource increasingly are stored in the networks such as Cloud Server cloud
In equipment, certain programs of present terminal of computing device usually require to obtain related resource on network at runtime, and
When Network status is poor, terminal of computing device can not access internet program can not normally obtain related resource then without
Method operation.And network-caching mechanism improves in optimization network response and has played important function, a good network on user experience
Program under complex network environment how Liu Chang operation, be somewhat dependent on the superiority and inferiority of network-caching mechanism.
However in iOS system of today, the buffering of iOS operating system can no doubt reach optimization second load network
The problem of resource, however such optimization is built upon on the basis of the limited memory of consumption, the system when Installed System Memory deficiency
Part cache resources can be abandoned, the operation of system meeting terminator, causes APP sudden strain of a muscle to be moved back, reduce user experience under serious situation.
This phenomenon embodies particularly evident in increasingly huge various APP programs.On the other hand, due to the mechanism of memory itself, when
User caches and can be emptied after exiting APP, and after second is opened APP, the resource loaded again can treat as new resources, need to carry out
Again it caches.
Summary of the invention
In view of this, the embodiment of the present invention is designed to provide a kind of offline cache loading method and device, to solve
Above-mentioned problems of the prior art.
In a first aspect, the embodiment of the invention provides a kind of offline cache loading method, the offline cache loading method
The Internet resources load request for obtaining the uniform resource locator comprising corresponding resource first searches for the unified money in memory
Finger URL corresponding resource in source searches for the resource if not searching the resource in the memory in external memory,
If searching the resource in the external memory, the resource is loaded into the memory.
Synthesis in a first aspect, search for the unification described after the acquisition Internet resources load request in memory
Before the caching of the corresponding resource of Resource Locator, the offline cache loading method further includes:Added according to the Internet resources
It carries request and determines that the resource belongs to the resource for needing to intercept;And the parameter flag based on the Internet resources load request
Position determines that the Internet resources load request is not belonging to secondary encapsulation request, and the secondary encapsulation request, which refers to, to be passed through
CanonicalRequestForRequest in NSURLProtocol agreement:Function carries out the request after secondary encapsulation.
Synthesis is in a first aspect, determine the network money in the parameter flag position based on the Internet resources load request
Source load request is not belonging to after secondary encapsulation request, and the offline cache loading method further includes:Pass through
canonicalRequestForRequest:Function carries out secondary encapsulation to Internet resources load request, obtains secondary encapsulation and asks
It asks;It is requested based on the secondary encapsulation, " it is fixed to search for the unified resource in memory using described in the execution of NSURLCache agreement
The step of corresponding resource of position symbol " to " resource is loaded into the memory ".
Synthesis described after the acquisition Internet resources load request according to the Internet resources in a first aspect, add
It carries request and determines that the resource belongs to before the resource for needing to intercept, the offline cache loading method further includes:Described in judgement
Whether Internet resources load request includes specific character string;If so, according to startLoading function execute described in " in memory
Search for the corresponding resource of the uniform resource locator " to " be packaged to the resource and complete to load " the step of;If it is not,
According to canInitWithRequest:Function " searches for the corresponding resource of the uniform resource locator " described in executing in memory
The step of to " be packaged to the resource and complete to load ".
It is comprehensive in a first aspect, it is described the resource is loaded into the memory after, including:The secondary encapsulation is requested
Carry out the addition of parameter flag position.
Synthesis is in a first aspect, after the memory by resource loading, and the offline cache loading method is also
Including:Judge whether the remaining amount of storage of the memory can cache the resource;If so, by the resource described
It is cached in memory;If it is not, the resource is cached in the external memory.
Second aspect, the embodiment of the invention provides a kind of offline cache loading device, the offline cache loading device
Module, resource searching module, resource is obtained including Internet resources load request to insmod and Resource Encapsulation module.The network
It includes corresponding resource that resource load request, which obtains module for obtaining Internet resources load request, the Internet resources load request,
Uniform resource locator.The resource searching module in memory or external memory for searching for the unified resource positioning
Accord with corresponding resource.When the resource is insmoded for searching the resource in the external memory, by the money
Source is loaded into the memory.The Resource Encapsulation module is for being packaged the resource and completing to load.
Comprehensive second aspect, the offline cache loading device further includes blocking module, and the blocking module includes intercepting
Judging unit and secondary encapsulation judging unit.The interception judging unit is used to determine institute according to the Internet resources load request
It states resource and belongs to the resource for needing to intercept.The secondary encapsulation judging unit is used for the ginseng based on the Internet resources load request
Number flag bit determines that the Internet resources load request is not belonging to secondary encapsulation request, and the secondary encapsulation request, which refers to, to be passed through
CanonicalRequestForRequest in NSURLProtocol agreement:Function carries out the request after secondary encapsulation.
The third aspect, the embodiment of the invention also provides a kind of calculating equipment, the calculating equipment includes bus and company
It is connected to processor, the memory of the bus, the memory is for storing computer instruction, and the processor is for executing institute
Computer instruction is stated, to execute above-mentioned method when executing the computer instruction.
Fourth aspect, the embodiment of the invention also provides a kind of storage medium, the storage medium is stored in computer,
The storage medium includes a plurality of instruction, and a plurality of instruction is configured such that the computer executes above-mentioned method.
Beneficial effect provided by the invention is:
The present invention provides a kind of offline cache loading method and device, the offline cache loading method in memory and
Search is with the presence or absence of the resource cached in external memory, and there are the resources in the memory or the external memory
Caching when be loaded directly into the resource, caching while realizing to the resource while carrying out memory and external memory,
Increase can offline cache stock number, make application program even if restart can also from local external memory load cache.Meanwhile
It first searches in the memory after obtaining Internet resources load request with the presence or absence of the resource cached, searches again for the external storage
With the presence or absence of the resource cached in device, auxiliary cache is carried out by external storage, slows down the use of memory described in system
Rate effectively improves caching loading velocity and Buffer Utilization.
Other features and advantages of the present invention will be illustrated in subsequent specification, also, partly be become from specification
It is clear that by implementing understanding of the embodiment of the present invention.The objectives and other advantages of the invention can be by written theory
Specifically noted structure is achieved and obtained in bright book, claims and attached drawing.
Detailed description of the invention
In order to illustrate the technical solution of the embodiments of the present invention more clearly, below will be to needed in the embodiment attached
Figure is briefly described, it should be understood that the following drawings illustrates only certain embodiments of the present invention, therefore is not construed as pair
The restriction of range for those of ordinary skill in the art without creative efforts, can also be according to this
A little attached drawings obtain other relevant attached drawings.
Fig. 1 is the cache responses flow chart of NSURLProtocol agreement and NSURLCache agreement;
Fig. 2 is a kind of flow chart for offline cache loading method that first embodiment of the invention provides;
Fig. 3 is a kind of flow chart for interception judgment step that first embodiment of the invention provides;
Fig. 4 is a kind of module map for offline cache loading device that second embodiment of the invention provides;
Fig. 5 is a kind of module diagram for calculating equipment that third embodiment of the invention provides.
Icon:100- offline cache loading device;110- Internet resources load request obtains module;120- resource searching mould
Block;130- resource insmods;140- blocking module;200- calculates equipment;201- memory;202- storage control;203-
Processor;204- Peripheral Interface;205- input-output unit;206- audio unit;207- display unit.
Specific embodiment
Below in conjunction with attached drawing in the embodiment of the present invention, technical solution in the embodiment of the present invention carries out clear, complete
Ground description, it is clear that described embodiments are only a part of the embodiments of the present invention, instead of all the embodiments.Usually exist
The component of the embodiment of the present invention described and illustrated in attached drawing can be arranged and be designed with a variety of different configurations herein.Cause
This, is not intended to limit claimed invention to the detailed description of the embodiment of the present invention provided in the accompanying drawings below
Range, but it is merely representative of selected embodiment of the invention.Based on the embodiment of the present invention, those skilled in the art are not doing
Every other embodiment obtained under the premise of creative work out, shall fall within the protection scope of the present invention.
It should be noted that:Similar label and letter indicate similar terms in following attached drawing, therefore, once a certain Xiang Yi
It is defined in a attached drawing, does not then need that it is further defined and explained in subsequent attached drawing.Meanwhile of the invention
In description, term " first ", " second " etc. are only used for distinguishing description, are not understood to indicate or imply relative importance.
First introduce below the invention relates to iOS system network frame Protocol Through Network caching resource processor
System:
Each step in offline cache loading method in the embodiment of the present application passes through NSURLProtocol agreement
And/or NSURLCache protocol realization.Referring to FIG. 1, Fig. 1 is the slow of NSURLProtocol agreement and NSURLCache agreement
Deposit responding process figure.
The NSURLProtocol agreement is the foundation of Cocoa Touch frame offer in URL Load System frame
On the basis of protocol interface, it is provided to the uniform resource locator of Internet resources load request or other kinds of request
(URL) it is handled.
Wherein, NSURLProtocol agreement is made of four core functions, i.e. canInitWithRequest:Function,
canonicalRequestForRequest:Function, initWithRequest:Function and startLoading function.It is described
canInitWithRequest:Function is for determining a need for the Internet resources load request that this protocol processes receives;Institute
State canonicalRequestForRequest:Function is used to carry out secondary envelope to Internet resources load request and corresponding resource
Dress obtains the secondary encapsulation request of NSCachedURLResponse variable format;The initWithRequest:Function is used for
The NSCachedURLResponse variable is handled, new NSCachedURLResponse variable is assembled and is sent to
System;The startLoading function is used to carry out resource load after required parameter group installs and finishes.
The URL request of the NSURLCache agreement application provides the synthesis caching mechanism on memory and disk, is base
A part of plinth class libraries URL load, any request by NSURLConnection/NSURLSession load all will be by
NSURLCache processing.
Wherein, the NSURLCache agreement includes a core function, i.e. cachedResponseForRequest:Letter
Number, the cachedResponseForRequest:Function identifies request by NSURLRequest, determines that the resource is
No needs caching and whether buffered, and then return to NSCachedURLResponse and give NSURLProtocol processing.
First embodiment
Through the applicant the study found that iOS system network frame agreement has upgraded the caching to Internet resources, caching mechanism
It is realized by loading on resource in memory.Frame can be stored in when loading new resources by resource sequence and by certain rule
In memory, when loading resource every time later, the resource loaded in memory will be obtained directly from memory, not needed again
Access network.Since the access speed of memory is there are clear superiority, APP usually in the case where second of load same asset,
Loading velocity can be promoted exponentially.But existing caching mechanism system when Installed System Memory deficiency can abandon part caching money
Source, under serious situation system can terminator operation, cause APP sudden strain of a muscle to be moved back, reduce user experience;Simultaneously because memory itself
Mechanism, caching after user exits APP can be emptied;And cacheable resource type as defined in iOS network frame agreement
It is very few, it not may customize, be not suitable for the demand that some projects need to cache specific resources.To solve the above-mentioned problems, originally
Invention first embodiment provides a kind of offline cache loading method.
Referring to FIG. 2, Fig. 2 is a kind of flow chart for offline cache loading method that first embodiment of the invention provides.Institute
Stating offline cache loading method, specific step is as follows:
Step S10:Terminal device obtains Internet resources load request, and the Internet resources load request includes corresponding resource
Uniform resource locator.
Step S20:The terminal device searches for the corresponding resource of the uniform resource locator in memory.
Step S30:If not searching the resource in the memory, the terminal device is searched in external memory
The resource.
Step S40:If searching the resource in the external memory, the resource is loaded by the terminal device
The memory.
For step S10, i.e.,:Terminal device obtains Internet resources load request, and the Internet resources load request includes
The uniform resource locator of corresponding resource.The terminal device can be the smart phone for being equipped with iOS operating system, personal electricity
Brain, server or other calculating treatmenting equipments.The Internet resources load request is that iOS system is needing to obtain money from network
Encapsulate when source one request, saves the total data that iOS system is sent to network server, including NSURL object, asks
Ask method, request header, request body etc..The uniform resource locator (Uniform Resource Locator, URL) is to can
It is indicated so that one kind of the position of the resource obtained from internet and access method is succinct, is the ground of standard resource on internet
Location, each file on internet have a unique URL, and the information that it includes points out that the position of file and browser are answered
How this handles it.
Pass through canonicalRequestForRequest:Function completes secondary encapsulation to the Internet resources load request
After obtaining secondary encapsulation request, step S20 and step S30 next should be executed, i.e., is searched in memory and external memory
The secondary encapsulation requests corresponding caching.Optionally, described search can be carried out by NSURLCache agreement, by described
The money that NSURLCache agreement requests corresponding cache resources to be identified and obtained, and will acquire the secondary encapsulation
Source is packaged into NSCachedURLResponse variable.
Next step S40 should be executed, i.e.,:If searching the resource in the external memory, the terminal
The resource is loaded into the memory by equipment.Optionally, the specific steps of step S40 can be:The NSURLProtocol association
The initWithRequest of view:cachedResponse:client:Function to the NSCachedURLResponse variable into
Row processing, assembles new NSCachedURLResponse variable, and the NSCachedURLResponse variable includes described
Then the resource is loaded into memory by the corresponding cache resources of Internet resources load request.
For step S10, the Internet resources load request, that is, NSURLRequest, and execute the step S20 it
Before, it is also necessary to pass through canInitWithRequest:Function judges whether to need this agreement to the Internet resources load request
NSURLRequest is intercepted.
The present embodiment additionally provides a kind of response judgement of interception judgment step progress Internet resources load request.It please refers to
Fig. 3, Fig. 3 show the process for intercepting judgment step, and specific step is as follows for the interception judgment step:
Step S11:The terminal process equipment determines that the resource belongs to needs according to the Internet resources load request
The resource of interception.
Step S12:Described in parameter flag position determination of the terminal process equipment based on the Internet resources load request
Internet resources load request is not belonging to secondary encapsulation request, and the secondary encapsulation request refers to through NSURLProtocol agreement
In canonicalRequestForRequest:Function carries out the request after secondary encapsulation.
It should be understood that count on one's fingers can for cacheable resource type as defined in the network frame agreement of existing iOS system
Number, not may customize, is not suitable for the demand that some projects need to cache specific resources, therefore in addition to general interception mechanism, this reality
The offline cache loading method for applying example further includes customized interception mechanism.Normally, general interception mechanism generally passes through money
Source suffix name and mime type intercept resource, such as the corresponding mime type of following active file type:" jpg, image/
Jpeg ", " bmp, image/bmp ", " png, image/png ", " tiff, image/tiff ", " svg, image/svg+xml ",
" wma, audio/x-ms-wma ", " wav, audio/x-wav ", " wmv, video/x-ms-wmv ", " zip, application/
Zip ", " doc, application/msword " and " txt, text/plain " etc., the Internet resources load of the above-mentioned type resource
It include above-mentioned universal character string in request.
Wherein, in order to identify that the Internet resources load request belongs to the place of customized interception mechanism or general interception mechanism
Type is managed, judgement should use the specific steps of customized interception mechanism or general interception mechanism can be for:Judge the network money
Whether source load request includes specific character string;If so, " searching for institute in memory according to described in the execution of startLoading function
State the corresponding resource of uniform resource locator " to " be packaged to the resource and complete to load " the step of;If it is not, according to
canInitWithRequest:Function " searches for the corresponding resource of the uniform resource locator " extremely described in executing in memory
The step of " resource is packaged and completes to load ".
For customized interception mechanism:For step S11, belong to customized interceptor in the Internet resources load request
When the processing type of system, according to canInitWithRequest:Value that request.rul in function is returned (with judge whether
It is identical by the way of customized interception mechanism) judge whether the Internet resources load request belongs to custom protocol, if
It is then to need to intercept resource;For step S12, by judging described in the parameter flag position determination of the Internet resources load request
Whether the Internet resources load request belongs to secondary encapsulation request, is in the parameter flag position
The Internet resources load request belongs to secondary encapsulation request when " ECPURLProtocolHandledKey ".
For general interception mechanism:For step S11, belong to general interception mechanism in the Internet resources load request
When handling type, judge whether to be intercepted by the Internet resources load request;For step S12, pass through judgement
The parameter flag position of the Internet resources load request determines whether the Internet resources load request belongs to secondary encapsulation
Request, when the parameter flag position is " ECPRequestHandledKey ", the Internet resources load request is secondary encapsulation
Request.
The present embodiment is enabled applications to by dividing customized interception mechanism and general interception mechanism in iOS system
Network frame under further types of resource is cached, improve the scope of application of caching.
Further, after executing the step S10, in order to be obtained and the network by NSURLCache agreement
The corresponding resource of resource load request, it is also necessary to execute following steps:
Step S13:The terminal process equipment passes through canonicalRequestForRequest:Function is to Internet resources
Load request carries out secondary encapsulation, obtains secondary encapsulation request.
After executing the step S20 and step S30 and completing resource searching, if the resource it is also possible to called, can
To be cached by memory to the resource, specific steps include:The terminal process equipment judges the residue of the memory
Whether amount of storage can cache the resource;If so, the terminal process equipment by the resource in the memory
It is cached;If it is not, the terminal process equipment caches the resource in the external memory.
It should be understood that in the reading of actual caching, certainly there is also all no pair in memory and external memory
The case where answering resource, the offline cache loading method provided in this embodiment will call in the case
NSURLConnection/NSURLSession function directly loads resource from network.Further, add in order to prevent from network
The resource of load is again introduced into caching process, it is therefore desirable to add parameter flag position, the parameter flag in secondary encapsulation request
The corresponding customized interception mechanism in position is " ECPURLProtocolHandledKey ", and corresponding general interception mechanism is
"ECPRequestHandledKey".Then the Resource Encapsulation finally obtained load is completed at NSURLResponse (to correspond to certainly
Define interception mechanism), or the Resource Encapsulation at NSCachedURLResponse and is transmitted to NSURLProtocol agreement
Until completing load (corresponding general interception mechanism).
The offline cache loading method provided in this embodiment gets net by NSURLCache agreement in iOS system
Resource corresponding with the Internet resources load request is successively searched for after network resource load request in memory and external memory,
Directly the resource is loaded after searching the resource, improves resource acquisition when Buffer Utilization and program operation
Speed solves the problems, such as to need to cache again after certain application programs exit.Meanwhile the offline cache loading method also needle
Two kinds of caching loading schemes of customized interception mechanism and general interception mechanism are provided with to iOS system, developer can be made by oneself
The agreement or standard HTTP of justice carry out network request interception and caching load, solve as defined in iOS network frame agreement
Cacheable resource type is very little, cannot customize, be unable to satisfy the demand that some application programs need to cache certain specific resources
The problem of.
Second embodiment
For the offline cache loading method for cooperating first embodiment of the invention to provide, second embodiment of the invention is also
Provide a kind of offline cache loading device 100.
Referring to FIG. 4, Fig. 4 is a kind of module map for offline cache loading device that second embodiment of the invention provides.
Offline cache loading device 100 includes that Internet resources load request obtains module 110,120 and of resource searching module
Resource insmods 130.
Internet resources load request obtains module 110, for obtaining Internet resources load request, the Internet resources load
Request includes the uniform resource locator of corresponding resource.
Resource searching module 120, it is corresponding for searching for the uniform resource locator in memory or external memory
Resource.
Resource insmods 130, and when for searching the resource in the external memory, the resource is loaded into
The memory.
Further, offline cache loading device 100 may include blocking module 140, and blocking module 140 includes intercepting to sentence
Disconnected unit and secondary encapsulation judging unit.The interception judging unit is used for according to Internet resources load request determination
Resource belongs to the resource for needing to intercept.The secondary encapsulation judging unit is used for the parameter based on the Internet resources load request
Flag bit determines that the Internet resources load request is not belonging to secondary encapsulation request, and the secondary encapsulation request, which refers to, to be passed through
CanonicalRequestForRequest in NSURLProtocol agreement:Function carries out the request after secondary encapsulation.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description
Specific work process, no longer can excessively be repeated herein with reference to the corresponding process in preceding method.
3rd embodiment
In order to realize above-mentioned step-recording method, third embodiment of the invention provides a kind of calculating equipment 200.It please refers to
Fig. 5, Fig. 5 are a kind of module diagram for calculating equipment that third embodiment of the invention provides.
Calculating equipment 200 may include offline cache loading device 100, memory 201, storage control 202, processor
203, Peripheral Interface 204, input-output unit 205, audio unit 206, display unit 207 and for each unit connection it is total
Line.Calculating equipment 200 is including the terminal process equipment in first embodiment of the invention.
The memory 201, storage control 202, processor 203, Peripheral Interface 204, input-output unit 205, sound
Frequency unit 206, each element of display unit 207 pass through bus between each other and are directly or indirectly electrically connected, to realize data
Transmission or interaction.It is electrically connected for example, these elements can be realized between each other by one or more communication bus or signal wire.
The offline cache loading device 100 includes that at least one can be stored in described deposit in the form of software or firmware (firmware)
In reservoir 201 or the software function that is solidificated in the operating system (operating system, OS) of offline cache loading device 100
It can module.The processor 203 is for executing the executable module stored in memory 201, such as offline cache loading device
100 software function modules or computer program for including.
Wherein, memory 201 may be, but not limited to, random access memory (Random Access Memory,
RAM), read-only memory (Read Only Memory, ROM), programmable read only memory (Programmable Read-Only
Memory, PROM), erasable read-only memory (Erasable Programmable Read-Only Memory, EPROM),
Electricallyerasable ROM (EEROM) (Electric Erasable Programmable Read-Only Memory, EEPROM) etc..
Wherein, memory 201 is for storing program, and the processor 203 executes described program after receiving and executing instruction, aforementioned
Method performed by the server that the stream process that any embodiment of the embodiment of the present invention discloses defines can be applied to processor 203
In, or realized by processor 203.
Processor 203 can be a kind of IC chip, the processing capacity with signal.Above-mentioned processor 203 can
To be general processor, including central processing unit (Central Processing Unit, abbreviation CPU), network processing unit
(Network Processor, abbreviation NP) etc.;Can also be digital signal processor (DSP), specific integrated circuit (ASIC),
Ready-made programmable gate array (FPGA) either other programmable logic device, discrete gate or transistor logic, discrete hard
Part component.It may be implemented or execute disclosed each method, step and the logic diagram in the embodiment of the present invention.General processor
It can be microprocessor or the processor 203 be also possible to any conventional processor etc..
Various input/output devices are couple processor 203 and memory 201 by the Peripheral Interface 204.Some
In embodiment, Peripheral Interface 204, processor 203 and storage control 202 can be realized in one single chip.Other one
In a little examples, they can be realized by independent chip respectively.
Input-output unit 205 realizes user and the server (or local terminal) for being supplied to user input data
Interaction.The input-output unit 205 may be, but not limited to, the equipment such as mouse and keyboard.
Audio unit 206 provides a user audio interface, may include one or more microphones, one or more raises
Sound device and voicefrequency circuit.
Display unit 207 provides an interactive interface (such as user's operation circle between the calculating equipment 200 and user
Face) or for display image data give user reference.In the present embodiment, the display unit 207 can be liquid crystal display
Or touch control display.It can be the capacitance type touch control screen or resistance of support single-point and multi-point touch operation if touch control display
Formula touch screen etc..Single-point and multi-point touch operation is supported to refer to that touch control display can sense on the touch control display one
Or at multiple positions simultaneously generate touch control operation, and the touch control operation that this is sensed transfer to processor 203 carry out calculate and
Processing.
It is appreciated that structure shown in fig. 5 is only to illustrate, the calculating equipment 200 may also include more than shown in Fig. 5
Perhaps less component or with the configuration different from shown in Fig. 5.Each component shown in Fig. 5 can use hardware, software
Or combinations thereof realize.
It is apparent to those skilled in the art that for convenience and simplicity of description, the device of foregoing description
Specific work process, no longer can excessively be repeated herein with reference to the corresponding process in preceding method.
In conclusion the embodiment of the invention provides a kind of offline cache loading method and device, the offline cache adds
Support method is search is with the presence or absence of the resource cached in memory and external memory, in the memory or the external storage
There are the resource is loaded directly into when the caching of the resource in device, realizes to the resource while carrying out memory and outside is deposited
Cached while reservoir, increase can offline cache stock number, make application program even if restart can also be from local external memory
Load caching.Meanwhile first searched for after obtaining Internet resources load request with the presence or absence of the resource cached in the memory, then
It searches for the presence or absence of the resource cached in the external memory, auxiliary cache is carried out by external storage, slows down system
Described in memory utilization rate, effectively improve caching loading velocity and Buffer Utilization.
In several embodiments provided herein, it should be understood that disclosed device and method can also pass through
Other functions are realized.The apparatus embodiments described above are merely exemplary, for example, flow chart and block diagram in attached drawing
Show the device of multiple embodiments according to the present invention, the architectural framework in the cards of method and computer program product,
Function and operation.In this regard, each box in flowchart or block diagram can represent the one of a module, section or code
Part, a part of the module, section or code, which includes that one or more is for implementing the specified logical function, to be held
Row instruction.It should also be noted that function marked in the box can also be to be different from some realization functions as replacement
The sequence marked in attached drawing occurs.For example, two continuous boxes can actually be basically executed in parallel, they are sometimes
It can execute in the opposite order, this depends on the function involved.It is also noted that every in block diagram and or flow chart
The combination of box in a box and block diagram and or flow chart can use the dedicated base for executing defined function or movement
It realizes, or can realize using a combination of dedicated hardware and computer instructions in the system of hardware.
In addition, each functional module in each embodiment of the present invention can integrate one independent portion of formation together
Point, it is also possible to modules individualism, an independent part can also be integrated to form with two or more modules.
It, can be with if the function is realized and when sold or used as an independent product in the form of software function module
It is stored in a computer readable storage medium.Based on this understanding, technical solution of the present invention is substantially in other words
The part of the part that contributes to existing technology or the technical solution can be embodied in the form of software products, the meter
Calculation machine software product is stored in a storage medium, including some instructions are used so that a computer equipment (can be a
People's computer, server or network equipment etc.) it performs all or part of the steps of the method described in the various embodiments of the present invention.
And storage medium above-mentioned includes:USB flash disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), arbitrary access are deposited
The various media that can store program code such as reservoir (RAM, Random Access Memory), magnetic or disk.
The foregoing is only a preferred embodiment of the present invention, is not intended to restrict the invention, for the skill of this field
For art personnel, the invention may be variously modified and varied.All within the spirits and principles of the present invention, made any to repair
Change, equivalent replacement, improvement etc., should all be included in the protection scope of the present invention.It should be noted that:Similar label and letter exist
Similar terms are indicated in following attached drawing, therefore, once being defined in a certain Xiang Yi attached drawing, are then not required in subsequent attached drawing
It is further defined and explained.
The above description is merely a specific embodiment, but scope of protection of the present invention is not limited thereto, any
Those familiar with the art in the technical scope disclosed by the present invention, can easily think of the change or the replacement, and should all contain
Lid is within protection scope of the present invention.Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
It should be noted that, in this document, relational terms such as first and second and the like are used merely to a reality
Body or operation are distinguished with another entity or operation, are deposited without necessarily requiring or implying between these entities or operation
In any actual relationship or order or sequence.Moreover, the terms "include", "comprise" or its any other variant are intended to
Non-exclusive inclusion, so that the process, method, article or equipment including a series of elements is not only wanted including those
Element, but also including other elements that are not explicitly listed, or further include for this process, method, article or equipment
Intrinsic element.In the absence of more restrictions, the element limited by sentence "including a ...", it is not excluded that
There is also other identical elements in process, method, article or equipment including the element.
Claims (10)
1. a kind of offline cache loading method, which is characterized in that the offline cache loading method includes:
Internet resources load request is obtained, the Internet resources load request includes the uniform resource locator of corresponding resource;
The corresponding resource of the uniform resource locator is searched in memory;
If not searching the resource in the memory, the resource is searched in external memory;
If searching the resource in the external memory, the resource is loaded into the memory.
2. offline cache loading method according to claim 1, which is characterized in that asked in acquisition Internet resources load
It is described offline after asking, and before the caching for searching for the corresponding resource of the uniform resource locator in memory
Caching loading method further includes:
Determine that the resource belongs to the resource for needing to intercept according to the Internet resources load request;And it is provided based on the network
The parameter flag position of source load request determines that the Internet resources load request is not belonging to secondary encapsulation request, the secondary encapsulation
Request refers to through the canonicalRequestForRequest in NSURLProtocol agreement:Function carries out secondary encapsulation
Request afterwards.
3. offline cache loading method according to claim 2, which is characterized in that added described based on the Internet resources
The parameter flag position for carrying request determines that the Internet resources load request is not belonging to after secondary encapsulation request, the offline cache
Loading method further includes:
Pass through canonicalRequestForRequest:Function carries out secondary encapsulation to Internet resources load request, obtains two
Secondary package request;
It is requested based on the secondary encapsulation, " searches for the unified resource in memory using described in the execution of NSURLCache agreement
The step of corresponding resource of finger URL " to " resource is loaded into the memory ".
4. offline cache loading method according to claim 2, which is characterized in that asked in acquisition Internet resources load
After asking, and it is described determine that according to the Internet resources load request, the resource belongs to the resource for needing to intercept before,
The offline cache loading method further includes:
Judge whether the Internet resources load request includes specific character string;
If so, " searching for the corresponding money of the uniform resource locator in memory according to described in the execution of startLoading function
The step of source " to " resource is packaged and completes to load ";If it is not, according to canInitWithRequest:Function is held
" search for the corresponding resource of the uniform resource locator in memory " described in row to " resource is packaged and complete plus
Carry " the step of.
5. offline cache loading method according to claim 3, which is characterized in that it is described will the resource be loaded into described in
After memory, including:
The secondary encapsulation is requested to carry out the addition of parameter flag position.
6. offline cache loading method according to claim 1, which is characterized in that it is described will the resource be loaded into described in
After memory, the offline cache loading method further includes:
Judge whether the remaining amount of storage of the memory can cache the resource;
If so, the resource is cached in the memory;If it is not, the resource is carried out in the external memory
Caching.
7. a kind of offline cache loading device, which is characterized in that the offline cache loading device includes:
Internet resources load request obtains module, for obtaining Internet resources load request, the Internet resources load request packet
Uniform resource locator containing corresponding resource;
Resource searching module, for searching for the corresponding resource of the uniform resource locator in memory or external memory;
Resource insmods, and when for searching the resource in the external memory, the resource is loaded into described
It deposits.
8. offline cache loading device according to claim 7, which is characterized in that the offline cache loading device also wraps
Blocking module is included, the blocking module includes:
Judging unit is intercepted, for determining that the resource belongs to the resource for needing to intercept according to the Internet resources load request;
Secondary encapsulation judging unit, for determining the Internet resources based on the parameter flag position of the Internet resources load request
Load request is not belonging to secondary encapsulation request, and the secondary encapsulation request refers to by NSURLProtocol agreement
canonicalRequestForRequest:Function carries out the request after secondary encapsulation.
9. a kind of calculating equipment, which is characterized in that the calculating equipment include bus and the processor for being connected to the bus,
Memory, the memory is for storing computer instruction, and the processor is for executing the computer instruction, to execute
When the computer instruction, such as method as claimed in any one of claims 1 to 6 is executed.
10. a kind of storage medium, which is characterized in that be stored with computer program instructions, the computer in the storage medium
When program instruction is read and run by a processor, perform claim requires the step in any one of 1-6 the method.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810760618.6A CN108846141B (en) | 2018-07-11 | 2018-07-11 | Offline cache loading method and device |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201810760618.6A CN108846141B (en) | 2018-07-11 | 2018-07-11 | Offline cache loading method and device |
Publications (2)
Publication Number | Publication Date |
---|---|
CN108846141A true CN108846141A (en) | 2018-11-20 |
CN108846141B CN108846141B (en) | 2022-05-24 |
Family
ID=64197076
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201810760618.6A Active CN108846141B (en) | 2018-07-11 | 2018-07-11 | Offline cache loading method and device |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN108846141B (en) |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111159238A (en) * | 2019-12-26 | 2020-05-15 | 厦门市美亚柏科信息股份有限公司 | Cache file evidence obtaining method based on IOS (input/output system), terminal equipment and storage medium |
Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101075241A (en) * | 2006-12-26 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method and system for processing buffer |
CN103686684A (en) * | 2012-09-20 | 2014-03-26 | 腾讯科技(深圳)有限公司 | Offline cache method and device |
CN105760232A (en) * | 2016-02-19 | 2016-07-13 | 四川长虹电器股份有限公司 | Offline cache method and system for IOS application |
CN105760405A (en) * | 2014-12-19 | 2016-07-13 | 阿里巴巴集团控股有限公司 | Methods and devices for obtaining network resource for loading web page and method and device for caching network resource |
US20160234331A1 (en) * | 2015-02-11 | 2016-08-11 | International Business Machines Corporation | Smart cache for offline data availability |
CN106372109A (en) * | 2016-08-19 | 2017-02-01 | 中国银联股份有限公司 | Internet resource file caching method and apparatus |
CN107203555A (en) * | 2016-03-17 | 2017-09-26 | 阿里巴巴集团控股有限公司 | Page loading processing method and device |
CN107332843A (en) * | 2017-07-01 | 2017-11-07 | 华泰证券股份有限公司 | IOS network requests intercept forwarding cache method and system |
-
2018
- 2018-07-11 CN CN201810760618.6A patent/CN108846141B/en active Active
Patent Citations (8)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101075241A (en) * | 2006-12-26 | 2007-11-21 | 腾讯科技(深圳)有限公司 | Method and system for processing buffer |
CN103686684A (en) * | 2012-09-20 | 2014-03-26 | 腾讯科技(深圳)有限公司 | Offline cache method and device |
CN105760405A (en) * | 2014-12-19 | 2016-07-13 | 阿里巴巴集团控股有限公司 | Methods and devices for obtaining network resource for loading web page and method and device for caching network resource |
US20160234331A1 (en) * | 2015-02-11 | 2016-08-11 | International Business Machines Corporation | Smart cache for offline data availability |
CN105760232A (en) * | 2016-02-19 | 2016-07-13 | 四川长虹电器股份有限公司 | Offline cache method and system for IOS application |
CN107203555A (en) * | 2016-03-17 | 2017-09-26 | 阿里巴巴集团控股有限公司 | Page loading processing method and device |
CN106372109A (en) * | 2016-08-19 | 2017-02-01 | 中国银联股份有限公司 | Internet resource file caching method and apparatus |
CN107332843A (en) * | 2017-07-01 | 2017-11-07 | 华泰证券股份有限公司 | IOS network requests intercept forwarding cache method and system |
Non-Patent Citations (1)
Title |
---|
3行代码: "NSURLProtocol 离线缓存", 《HTTPS://BLOG.CSDN.NET/JIANG314/ARTICLE/DETAILS/53894821》 * |
Cited By (1)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN111159238A (en) * | 2019-12-26 | 2020-05-15 | 厦门市美亚柏科信息股份有限公司 | Cache file evidence obtaining method based on IOS (input/output system), terminal equipment and storage medium |
Also Published As
Publication number | Publication date |
---|---|
CN108846141B (en) | 2022-05-24 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
AU2019340314B2 (en) | Dynamic application migration between cloud providers | |
US10372596B2 (en) | Distributed system test device | |
Yadav et al. | LARAVEL: a PHP framework for e-commerce website | |
CN108156022A (en) | A kind of service calling method, device and electronic equipment | |
CN107798108B (en) | Asynchronous task query method and device | |
CN107423085B (en) | Method and apparatus for deploying applications | |
CN108415832A (en) | Automatic interface testing method, device, equipment and storage medium | |
CN114095567B (en) | Data access request processing method and device, computer equipment and medium | |
CN108536617B (en) | Cache management method, medium, system and electronic device | |
CN107016045A (en) | A kind of method and device of paged data inquiry | |
CN110120971A (en) | A kind of gray scale dissemination method, device and electronic equipment | |
CN109947624A (en) | Method for monitoring state and device | |
CN107678805A (en) | The call method and device of a kind of application programming interfaces | |
CN110266555A (en) | Method for analyzing web site service request | |
CN109639801A (en) | Back end distribution and data capture method and system | |
CN109670126A (en) | A kind of cross-border access accelerating method and device | |
CN108846141A (en) | A kind of offline cache loading method and device | |
CN107908552A (en) | A kind of test method based on link, device and equipment | |
CN110020297A (en) | A kind of loading method of web page contents, apparatus and system | |
CN108011936A (en) | Method and apparatus for pushed information | |
WO2020024902A1 (en) | Method, device, and storage medium for searching for blockchain data | |
US10554770B2 (en) | Dynamic cognitive optimization of web applications | |
CN109901892A (en) | A kind of method and apparatus of dynamic attribute verifying | |
CN110020166A (en) | A kind of data analysing method and relevant device | |
CN109992614B (en) | Data acquisition method, device and server |
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 | ||
GR01 | Patent grant | ||
GR01 | Patent grant |