Web Performance & Optimization MCQs for the NSCT

By the NSCT Exam Editorial Team · Updated 2026-11-24 · Facts checked against official sources on 2026-11-24

Web performance optimisation means making pages load, respond and stay visually stable faster, mainly through caching, smaller files (minification and compression), lazy loading and measuring the result with Core Web Vitals. It is the 13th of the 17 topics in the Web Development area, which carries 10% of the NSCT according to HEC's Areas of Competencies.

Web was the strongest area in 2026 at 54.1% accuracy, per APP and the HEC NSCT report. Expect short calculations (hit ratios, payload sizes, download times) and "which fix targets the cause" questions. The HTTP headers involved come from Web Architecture & Protocols.

Caching

A cache keeps a copy of a response so later requests skip some or all of the network. Browsers, CDNs (content delivery networks, which serve copies from edge servers near the user) and service workers all cache. The Cache-Control header sets the rules:

Directive Meaning
max-age=3600 Fresh for 1 hour; reused with no request
no-cache May store, but must revalidate before each use
no-store Must not store at all
immutable Will never change; do not revalidate

When a copy goes stale, the browser revalidates with If-None-Match (carrying the ETag) and gets 304 Not Modified with no body if nothing changed. Long-lived assets use content-hashed filenames such as app.3f9a2c.js, so a new release gets a new URL.

Hit ratio = hits / (hits + misses). With a 0.9 hit ratio, 20 ms hits and 200 ms misses, the average is 0.9 × 20 + 0.1 × 200 = 38 ms.

Exam angle: no-cache does not mean "do not cache". That is no-store.

Minification

Minification removes whitespace, comments and long local names at build time without changing behaviour. Compression (gzip or Brotli) then encodes repeated patterns during transfer, so the savings stack: a 400 KB file minified by 30% and then gzipped to 25% sends 400 × 0.7 × 0.25 = 70 KB.

Related build steps are bundling (combining modules), tree shaking (dropping unused ES module exports) and code splitting (loading chunks on demand with import()).

Exam angle: minification is not encryption and not compression; it is a source rewrite.

Lazy loading

Lazy loading postpones resources until they are needed. For images, <img loading="lazy"> waits until the image nears the viewport. For code, dynamic import() loads a module only when a route uses it. For scripts, defer downloads in parallel and runs in document order after parsing, while async runs each script as soon as it arrives, in no fixed order.

Exam angle: never lazy-load the hero image above the fold. It is usually the LCP element, and lazy loading delays it.

Core Web Vitals

Google's Core Web Vitals measure real-user experience. Since 12 March 2024, INP (Interaction to Next Paint) has replaced FID (First Input Delay).

Metric Measures Good Poor
LCP (Largest Contentful Paint) Loading ≤ 2.5 s > 4 s
INP (Interaction to Next Paint) Responsiveness ≤ 200 ms > 500 ms
CLS (Cumulative Layout Shift) Visual stability ≤ 0.1 > 0.25

Values between the two columns "need improvement". A page passes when the 75th percentile of real page loads is good. Each layout shift scores impact fraction × distance fraction, and CLS is the largest burst (session window) of shifts. Lab tools such as Lighthouse simulate one load; field data such as CrUX (Chrome User Experience Report) comes from real users.

Exam angle: older notes still list FID with a 100 ms threshold. Current answers use INP and 200 ms.

Common traps

Worked examples

1. Understanding. Which header lets a browser store a response but forces it to check with the server before every reuse? Answer: Cache-Control: no-cache. no-store forbids storage entirely.

2. Application. An edge cache answers 720 of 900 requests itself. What share of requests reaches the origin? Answer: misses = 900 − 720 = 180, and 180 / 900 = 20%. The hit ratio is 80%.

3. Analysis. A news page shows CLS 0.28 because web fonts load late and the text reflows, and images have no size attributes. What should you fix first? Answer: give images width and height (or aspect-ratio) so the browser reserves space, and use a font-loading strategy with a size-matched fallback. Both remove the shifts; faster servers only move them earlier.

Practise

The quiz below has 100 questions on this topic, filterable by tier and difficulty.

Practise: 100 questions

Interactive quiz loading. The first 10 questions are shown below.

  1. Which Core Web Vital measures loading performance?

    1. Largest Contentful Paint (LCP)
    2. Interaction to Next Paint (INP)
    3. Cumulative Layout Shift (CLS)
    4. Time to First Byte (TTFB)
    Show answer

    Answer: A. Largest Contentful Paint (LCP)

    LCP reports when the largest image or text block in the viewport finishes rendering, so it is Google's loading metric. INP measures responsiveness, CLS measures visual stability, and TTFB is a useful diagnostic but not a Core Web Vital.

  2. In March 2024, which metric replaced First Input Delay (FID) as a Core Web Vital?

    1. Total Blocking Time (TBT)
    2. Interaction to Next Paint (INP)
    3. First Contentful Paint (FCP)
    4. Time to Interactive (TTI)
    Show answer

    Answer: B. Interaction to Next Paint (INP)

    Google made INP a stable Core Web Vital on 12 March 2024 and retired FID. FID measured only the input delay of the first interaction; INP covers all interactions through to the next paint. TBT is a lab proxy, and FCP and TTI are not Core Web Vitals.

  3. Which set lists Google's current 'good' thresholds for the three Core Web Vitals?

    1. LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1
    2. LCP ≤ 4 s, INP ≤ 500 ms, CLS ≤ 0.25
    3. LCP ≤ 2.5 s, INP ≤ 100 ms, CLS ≤ 0.1
    4. LCP ≤ 1.8 s, INP ≤ 200 ms, CLS ≤ 0.05
    Show answer

    Answer: A. LCP ≤ 2.5 s, INP ≤ 200 ms, CLS ≤ 0.1

    Good means LCP at or under 2.5 s, INP at or under 200 ms and CLS at or under 0.1. The 4 s, 500 ms and 0.25 values are the 'poor' boundaries, 100 ms was the old FID threshold, and 1.8 s is the good threshold for FCP, not LCP.

  4. Google assesses a page's Core Web Vitals from field data at which percentile of page loads?

    1. 75th percentile
    2. 50th percentile (median)
    3. 90th percentile
    4. 95th percentile
    Show answer

    Answer: A. 75th percentile

    A page passes a metric when at least 75% of real page loads meet the 'good' threshold, i.e. the 75th percentile value is good, measured separately for mobile and desktop. The median would hide a large share of slow visits.

  5. Which statement best describes what INP measures?

    1. Only the delay before the browser starts handling the very first interaction
    2. How long scrolling takes to respond on touch devices
    3. The latency of clicks, taps and key presses across the whole visit, from input until the next frame is painted, reporting about the worst one
    4. The time until the main thread is quiet for five seconds after load
    Show answer

    Answer: C. The latency of clicks, taps and key presses across the whole visit, from input until the next frame is painted, reporting about the worst one

    INP observes every click, tap and keyboard interaction during the page's lifetime, measures input delay plus processing plus presentation delay up to the next paint, and reports one of the slowest (ignoring rare outliers on busy pages). The first option is FID, scrolling is excluded from INP, and the last is the old TTI idea.

  6. What does minification do to a JavaScript or CSS file?

    1. Compresses the file with gzip each time it is requested
    2. Encrypts the code so users cannot read it
    3. Removes whitespace and comments and shortens local names without changing behaviour
    4. Merges every script on the site into one file
    Show answer

    Answer: C. Removes whitespace and comments and shortens local names without changing behaviour

    Minification is a build-time rewrite: comments, whitespace and long local identifiers go, behaviour stays the same. Gzip or Brotli compression is a separate transfer encoding, minified code is still readable after formatting, and merging files is bundling.

  7. What does the response header Cache-Control: no-cache tell a browser?

    1. It may store the response but must revalidate it with the server before each reuse
    2. It must never store the response anywhere
    3. Only the browser, not a CDN, may cache the response
    4. It may reuse the response forever without checking
    Show answer

    Answer: A. It may store the response but must revalidate it with the server before each reuse

    Despite its name, no-cache allows storage but forces revalidation (for example with If-None-Match) before use. no-store forbids storage, private limits caching to the browser, and 'forever without checking' describes a long max-age with immutable.

  8. What does the attribute loading="lazy" on an <img> element do?

    1. Defers fetching the image until it is close to entering the viewport
    2. Loads the image at a lower resolution first
    3. Downloads the image only after the whole page finishes loading
    4. Stops the image from ever being cached
    Show answer

    Answer: A. Defers fetching the image until it is close to entering the viewport

    Native lazy loading lets the browser postpone off-screen images until the user scrolls near them, saving bandwidth on images that may never be seen. It does not change resolution (that is srcset or progressive JPEG) and has nothing to do with caching.

  9. What is the purpose of an ETag response header?

    1. It is a validator; the browser sends it back in If-None-Match and gets 304 Not Modified if the resource is unchanged
    2. It tells the CDN how many seconds to keep the file
    3. It encrypts the response body for HTTPS
    4. It forces a 302 redirect to the latest version
    Show answer

    Answer: A. It is a validator; the browser sends it back in If-None-Match and gets 304 Not Modified if the resource is unchanged

    An ETag is an identifier for one version of a resource. On revalidation the browser sends If-None-Match with it, and if it still matches the server answers 304 with no body. Freshness lifetime is set by max-age, and TLS, not ETag, handles encryption.

  10. What is the main performance benefit of a Content Delivery Network (CDN)?

    1. Minifying the site's JavaScript automatically
    2. Serving cached copies from edge servers near the user, cutting round-trip time and origin load
    3. Replacing the need for a database
    4. Making every response uncacheable so content is always fresh
    Show answer

    Answer: B. Serving cached copies from edge servers near the user, cutting round-trip time and origin load

    A CDN keeps copies of static (and sometimes dynamic) content at many edge locations. A user in Lahore can be served from a nearby edge instead of a distant origin, so latency falls and the origin handles fewer requests. Some CDNs also minify, but that is not their core purpose.

FAQs

Is minification the same as compression?

No. Minification rewrites the source at build time by removing spaces, comments and long names. Compression such as gzip or Brotli encodes the bytes during transfer, and the browser decompresses them. You normally use both, because compression still finds repeated patterns in minified code.

Which Core Web Vitals should I learn for the exam?

Learn LCP, INP and CLS with their thresholds: 2.5 s, 200 ms and 0.1 for good, and 4 s, 500 ms and 0.25 for poor. INP replaced FID in March 2024, so treat FID as a historical metric. Also remember that the assessment uses the 75th percentile of real page loads.

When should I use a CDN?

Use one when users are spread far from your server or when static files make up most of your traffic. A CDN cuts round-trip time and offloads the origin. Its gain depends on the hit ratio, so cache headers and hashed filenames matter as much as the CDN itself.

What is the difference between preload and prefetch?

preload fetches a resource the current page needs soon, at high priority, such as the hero image or a key font. prefetch fetches something the next page will probably need, at low priority when the browser is idle. Misusing preload can compete with more important downloads.

Next step

Continue with Web Testing & Debugging, the next topic in HEC's order. You can also return to the Web Development MCQs hub or test yourself in an NSCT mock test.