what is caching
the process of storing previously used data in a location (cache) so that it can be quickly accessed to speed up retrieval if it is needed in the future
what is pre- fetching
when data is fetched and stored in a cache or buffer before it is needed e.g when streaming a video file, successive seconds/minutes of stream data are buffered. Algorithms must be able to correctly predict what will be needed.
what is cache miss
occurs when a system or application requests data from a cache, but the data is not found
what is a library
a collection of reusable subroutines that a programmer can “call” when writing code so that the programmer doesn’t have to write this code
what are reusable components
reusing existing assets in some form within the software product development process including code e.g. subroutines, classes, libraries, designs and documentation
describe web browser cache, including pros and cons
browsers cache frequently used web page sheets/ scripts to reduce the number of requests that go to the web server
pros- faster load time, reduced network traffic e.g. fewer HTTP requests
Cons - cached resource may be out of date
describe caching proxy server, including pros and cons
proxies act as intermediaries between the client and the origin server
cache server (proxy server) saves previously requested web pages or other content
pros - Faster load time as HTTP request does not have to go to original web server, reduces network traffic
cons - cached resource may be out of date
describe DNS cache, including pros and cons
DNS, domain name system, is used to resolve a particular domain name to its IP equivalent
when a DNS server responds to a DNS request, the operating system may store these results in a local DNS cache
Pros - reduced network traffice e.g. fewer DNS requests, reduced network traffic as there will be fewer DNS requests to remote DNS servers
Cons - cached resource may be out of date, if a web page has changed the location of its web server in the time since its IP address was cached, a web browser might return an HTML 404 error—although the site is still online. Cache could be maliciously changed to direct users to different sites
describe CPU cache, including pros and cons
CPUs have onboard cache to store frequently used data/instructions
it is faster to access the cache than it is to access main memory (RAM) because:
- it’s physically located on the chip
- cache uses SRAM which is faster rather than DRAM which is used for main memory
CPUs have a hierarchy of cache e.g. L1 to L3 with L1 being the smallest and therefore quickest to search.
modern CPUs have L1 cache for instructions and L1 cache for data. L2 is often shared by cores.
when the processor needs to read or write a location in memory, it first checks for a corresponding entry in the cache. If the processor finds that the memory location is in the cache, a cache hit has occurred and the processor immediately reads/writes to the cache. if not, a cache miss has occurred and the data is copied from main memory into cache and the request fulfilled from cache
Pros - Faster response time
Cons - small size (will never hold everything but a smaller program means more of it fits into cache, the CPU needs to have good cache algorithms to decide what to discard to make space for new data/instructions to minimise cache misses), SRAM is expensive, fixed sized (can’t be increased, if you want more you need to buy a new CPU)
describe hard disk drives, including pros and cons
cache stores the most recent and frequently used programs/data from the drive
hard drive cache (HDC) is also known as a disk buffer
modern hard disks come with fast memory, around 512 kilobyte. If the CPU requests data from the hard disk, the hard-disk controller checks this memory before moving the mechanical parts of the hard disk (which is very slow compared to memory). If it finds the data that the computer asked for in the cache, it will return the data stored in the cache without actually accessing data on the disk itself, saving a lot of time
Pros - Faster response time
Cons - small size (will never hold everything), fixed sized (can’t be increased)
what are the pros of reusing program code (5)
what are the cons of using reusable program code (4)