iTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Need a server to try this on? Antihost offers Linux VPS plans with NVMe storage, full root access and a 14-day free trial.
Use Nginx’s expires directive in the http, server, or an appropriate location block. For example, expires 7d; tells Nginx to send Cache-Control: max-age=604800 and a matching future Expires date for successful static-file responses. Put the rule on the location that serves your CSS, JavaScript, images, fonts, or other cacheable assets, test the configuration, reload Nginx, and verify the response with curl -I.
What the Nginx expires directive does
The expires directive belongs to Nginx’s ngx_http_headers_module. It adds or updates two HTTP response headers:
Recommended Free Tools
Expires, an absolute date after which a stored response is considered stale.Cache-Control: max-age=..., a lifetime in seconds for the cached response.
Those headers control how a browser or an intermediate cache reuses a response. They do not make Nginx keep a separate copy in its own proxy cache. A browser can reuse a fresh CSS file without opening a new connection to your origin; when the lifetime ends, the browser can request the resource again and obtain the current version.
The directive is disabled by default (off). It affects responses with status codes 200, 201, 204, 206, 301, 302, 303, 304, 307, and 308. Responses with other status codes are not given an expiration policy by this directive.
#1 Best Overall
- Powerful Turbo Fan:CAGIWIRU Electric Air Duster have reached speed up to 130000RPM,Can efficient remove dust and debris.With LED light and Three Adjustable Speed to meet with different cleaning tasks.
- With Attached USB C Fasting Charging cable.Charing 3 hours,Enjoy up to 240 minutes of use on the lowest setting, For third speed can use for 25mins.with four charging options to meet with your needs.
- Wide Application:Upgraded attached 5 different nozzles,making it suitable for a variety of scenes, such as car,pet, pc, keyboards, and other electronic devices. It also serves for office and home clean duster.
- Handy Design & Portable:Cordless air duster electric nozzle is Light weight and small size, design and comfortable to hold and space saving, convenient to carry around. You can put it in your room or inside the car without taking up space.
- Warranty & Support: Our Electric air duster comes with 5 years warranty and 24/7 customer service. During this period, if you have any questions,pls kindly feel free to contact us.
Basic configuration
A common starting point is a regular-expression location for static extensions:
server {
listen 443 ssl;
server_name example.com;
root /var/www/example;
location ~* .(?:css|js|jpg|jpeg|png|gif|svg|webp|ico|woff|woff2|ttf|eot)$ {
expires 7d;
}
}
After adding the rule, check and reload the configuration:
sudo nginx -t
sudo systemctl reload nginx
Then inspect one real asset:
curl -I https://example.com/path/file.css
A successful response should include a Cache-Control value such as max-age=604800 (seven days) and an Expires date in the future. The exact date depends on when Nginx generated the response.
Directive syntax, scope, and inheritance
The supported forms are:
expires [modified] time;
expires epoch;
expires max;
expires off;
You can use the directive in http, server, location, and an if inside a location. In practice, a narrowly targeted location is safest because it prevents HTML pages, API responses, login screens, and other changing content from receiving a long browser lifetime.
| Form | Result | Typical use |
|---|---|---|
expires 7d; |
Sets Cache-Control: max-age=604800 and an Expires date seven days from the response time. |
Static files whose names may be reused after an update. |
expires 0; |
Sets Cache-Control: max-age=0 and an expiration time of now. |
Explicitly making a resource immediately stale while still using the directive’s generated headers. |
expires -1; (or another negative interval) |
Sets Cache-Control: no-cache. |
Responses that must be checked with the origin before reuse. |
expires modified 24h; |
Calculates expiration from the file’s modification time plus 24 hours, rather than from the request time. | Policies tied to deployment or file timestamps. |
expires @15h30m; |
Expires at the next specified time-of-day according to Nginx’s time-of-day syntax. | Daily expiration boundaries; supported since Nginx 0.7.9 / 0.6.34. |
expires max; |
Sets Expires to 31 December 2037 23:55:55 GMT and Cache-Control to ten years (max-age=315360000). |
Immutable, content-hashed assets whose URLs change whenever content changes. |
expires epoch; |
Sets Expires to 1 January 1970 00:00:01 GMT and Cache-Control: no-cache. |
Explicitly stale responses and cache-bypass behavior. |
expires off; |
Leaves existing Expires and Cache-Control headers unchanged. This is the default. |
Locations where another module or upstream application owns cache headers. |
Positive and zero intervals are converted to seconds for max-age. For example, 30 minutes becomes 1,800 seconds and 30 days becomes 2,592,000 seconds.
Choose a lifetime that matches your asset naming
| Asset situation | Example policy | Why |
|---|---|---|
| Filename stays the same when content changes | expires 1h; to expires 7d; |
A shorter lifetime limits how long a browser can display an old file after deployment. |
Filename includes a build hash or version, such as app.4f91c2.js |
expires 1y; or expires max; |
Changing the filename creates a new cache key, so an old copy cannot mask the new URL. |
| Fonts and images are replaced in place | expires 7d; or another measured interval |
These files are usually stable, but an in-place replacement still needs a way to reach visitors before a year has elapsed. |
| HTML documents, account pages, and API responses | Do not apply a broad static-asset rule; use an application-specific policy. | These responses often depend on a session, authorization, or rapidly changing data. |
A one-year lifetime is appropriate only when your deployment process guarantees that a changed file receives a different URL. Otherwise, visitors can retain the old response until it becomes stale.
PC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minuteStep-by-step: add headers to static files
1. Find the server block that serves the files
Open the enabled Nginx site configuration and identify the server block whose root or alias points to your public files. On many Linux installations, site files are included from a directory under /etc/nginx, but the exact layout depends on the operating system and package.
Rank #2
- Screen Cleaner is Your Screen’s New Bestfriend! - EVEO is proud to present a screen cleaner that’s perfectly suited for your TV. Meet your new screen cleaner, computer screen cleaner, laptop cleaner, iPad cleaner, Macbook,tv cleaner or any other electronic device. Our screen cleaner spray and wipe along with the included plush microfiber cloth, easily removes dust, fingerprints & other smudges on the screen’s surface. Clean effectively for a streak-free screen
- Gentle on your Screens - Our screen cleaner spray and wipes is compatible to be used even for the most sensitive LCD, LED, CRT, and OLED screens in proper use. Be at ease knowing that this product is compatible with all the major brands: LG, SONY, Samsung, Sharp, iPad, iPhone, Android screens, Kindle, PC monitors - we’ve got you covered! Can be used as LCD screen cleaner, tv cleaner, smart tv screen cleaner, and more
- Premium Super Soft Plush Microfiber Cloth - Included in this efficient screen cleaning kit. This screen cleaner spray and wipe has our signature plush microfiber cloth specially designed to comply with screens and monitors and leave them streak-free. Has been shown to effectively absorbs stubborn stains, zero streaks, and no fiber shedding. Always use this together with our screen cleaner for the best results
- Easy-to-Use Screen Cleaner Kit + microfiber cleaning cloth - The EVEO Screen Cleaning Kit will easily be your new favorite tool when it comes to taking care of the things you love most, quick and easy solution for a streak-free screen. Simply screw on the sprayer gun on the screen cleaner bottle. Spray the cleaning liquid onto the microfiber cloth, then wipe the screen until desired cleanliness & shine is achieved.
- Quality Screen Care Kit Worth Purchasing - Enjoy a convenient Screen Cleaner anytime, anywhere you need it. Your satisfaction is our top priority. We stand behind the quality of our products and that’s why, you shouldn’t be worrying at all. We manufacture the Best Screen Cleaner. and can be used for laptop cleaning kit, laptop screen cleaner, tv screen cleaner for smart tv. MacBook screen cleaner, monitor cleaner or screen cleaner spray for electronic devices with microfiber cleaning cloth
Confirm the URL maps to a file that Nginx serves directly. If a framework, application server, or content-delivery layer generates the response, its headers may need to be changed there instead.
2. Add a narrowly matched location
For ordinary assets, add a case-insensitive extension match:
location ~* .(?:css|js|mjs|map|jpg|jpeg|png|gif|svg|webp|avif|ico|woff|woff2|ttf|otf|eot)$ {
expires 7d;
}
Include only extensions you actually serve. A source map may contain sensitive source information; cache it only if exposing it is intentional.
3. Select a longer policy for fingerprinted files
If your build produces hashed names, give those files a long lifetime:
location ~* .(?:[0-9a-f]{8,}.)?(?:css|js|mjs)$ {
expires 1y;
}
Adapt the pattern to your naming scheme. The important condition is not the regular expression itself but the guarantee that a content change changes the URL.
4. Validate the syntax before reloading
sudo nginx -t
Do not reload if the test reports an error. Correct missing semicolons, braces, certificate paths, or an invalid directive value first.
5. Reload without dropping connections
sudo systemctl reload nginx
A reload asks Nginx workers to pick up the new configuration while existing connections finish. The command varies on systems that use a different service manager; the equivalent Nginx reload signal is nginx -s reload when run with the required privileges.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Rank #3
- 【Large size】:Measuring 800 x 300 mm/ 31. 5×12 inches, which is wider and taller than others. Large mouse pad can perfectly fit your keyboard and mouse of any size, and there is also ample space for peripherals such as phones, tablets, etc.
- 【LED backlight mouse pad】:Blade Hawks RGB mouse pad provides 7 static modes and 7 dynamic modes will give you the options you are looking for. Power-off memory function remembers the last lighting mode you selected. The super glow fiber Chroma will give you a colorful gaming setup that you want.
- 【Anti-slip rubber base】:Made from Natural rubber, this gaming mousepad will firmly grip your desktop, allowing you to enjoy the ultimate precision in the games you are most passionate about. It also comes with a texture that enhances this ability even further.
- 【Smooth and waterproof surface】: Micro-textured cloth surface, for extremely precise mouse control and a smooth movement. When liquid splashes on the gaming mouse pad, it forms water droplets and slides down. Will not delay your work or gameplay.
- 【Plug and play】: This mouse and keyboard pad is powered by USB, plug and play, no driver required. One button control light modes. Press one time to change the lighting mode, press twice to change the brightness, press and hold about 3 seconds turn ON/OFF.
6. Verify the actual response
curl -I https://example.com/path/file.css
Check the status code, Cache-Control, and Expires. Test a URL that is handled by the intended location, not merely a similar filename. A response from an upstream application, CDN, or different virtual host can make a correct Nginx rule appear ineffective.
Using modified and time-of-day expiration
With modified, Nginx bases the expiration calculation on the file’s modification timestamp:
location /downloads/ {
expires modified 24h;
}
If the file was modified at 09:00, its generated expiration is 09:00 the following day, regardless of when each visitor first requested it. This differs from expires 24h;, which gives each response a 24-hour lifetime measured from the response time.
The time-of-day form can align expiry with an operational boundary:
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorslocation /daily/ {
expires @15h30m;
}
Use this only when a daily cutoff is genuinely useful. A time-of-day policy can produce a much shorter lifetime for a request made shortly before the cutoff.
Set different lifetimes with a map
Since Nginx 1.7.9, the value of expires can be a variable. A map in the http context lets one location choose a policy from the request URI:
http {
map $uri $asset_expires {
default off;
~*.pdf$ 42d;
~*.(?:jpg|jpeg|png|gif|svg|webp)$ max;
}
server {
listen 443 ssl;
server_name example.com;
root /var/www/example;
location / {
expires $asset_expires;
}
}
}
In this example, PDF files receive 42 days, the listed image types receive the ten-year max policy, and everything else keeps its existing headers because the map defaults to off. Place the map at http scope; placing it inside a server or location block is invalid.
Rank #4
- 【Softer and More Comfortable】Vaydeer wrist rest has unique diamond pattern, which is the combination of softness and aesthetics. The materials of wrist rest are improved into higher quality memory foam and covered with silky smooth lycra. The computer wrist rest makes you as comfortable and cushiony as like rest your wrists on clouds.
- 【Ergonomic Wrist Saver】The wrist rests for keyboard and mouse comes with a 17.32×3.15×0.83 inch keyboard wrist pad and a 5.94×3.15×0.83 inch mouse wrist support. Based on ergonomic design, the unique concave shape is the perfect fit for your wrist joints. The wrist rest pad fits most computer keyboards and laptops, improve hand and wrist posture, release your wrist and arm stress.
- 【Non-Slip Rubber Bottom】Featuring an anti-skid silicone base on the bottom, this wrist keyboard support stays firmly in place on your desk, preventing the padding from sliding around, ensuring stable and consistent wrist support during extended computer sessions.
- 【Better Experience & Pain Relief】Our keyboard arm rest is beneficial to alleviate the soreness caused by direct contact and friction between your arm and a hard desk surface, reducing the risk of wrist fatigue or carpal tunnel. The soft texture of memory foam can evenly distribute the pressure around your wrists and provide good support with just enough give.
- 【Helpful in Multiple Scenarios】Whether you're working, studying, writing, typing, gaming, this keyboard and mouse rest combo is an essential accessory to add comfort and support to your hands and wrists. It’s also a great gift for men, women, family, friend, coworker, gamer, teacher, etc.
Before using a long image policy, confirm that image URLs are versioned or content-hashed. If an image is replaced at the same URL, a browser can continue displaying its cached copy.
Free tools Windows power users keep installed
One-click scans. No signup required.
When you need immutable
The expires directive does not add the immutable cache-control token. If your clients and deployment model require that exact policy, add the complete header explicitly:
location ~* .(?:css|js)$ {
add_header Cache-Control "public, max-age=31536000, immutable" always;
}
Use one source of truth for Cache-Control in a location. Do not combine this custom header with expires in the same location, because the response can contain duplicate or contradictory cache instructions. If you need immutable, replace the expires line for that location rather than adding both.
Location matching can prevent the rule from applying
Nginx does not merge every matching location. When multiple regular-expression locations match a request, Nginx uses the first matching regular-expression location it reaches in configuration order. For example, if one pattern matches all .css files and an earlier pattern handles a broader group that also includes .css, the earlier pattern wins and its headers are sent.
Keep related regex locations together and order them deliberately. A more specific pattern should appear before a broader one. Also remember that a prefix location can be modified by the regular-expression search unless it uses the ^~ modifier, so inspect the complete server configuration when debugging.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →What the response headers mean
Cache-Control: max-age
The number is seconds. max-age=604800 represents seven days; max-age=31536000 represents 365 days. Nginx calculates this value from the interval you specify.
Expires
This is an absolute GMT date. Nginx sends it alongside the calculated max-age for positive and zero intervals. Seeing a future date confirms that the directive was applied, but the browser’s complete caching decision can also depend on other response headers and request conditions.
Best Value
- 【No Drill Mounted】Cable management tray can be assembled in as little as 3 minutes or less-simply. Side clips easily clampe the edge of desk, pass through the holes on the sides, and secure excess cables with baskets. Desk cable management supports inward or outward installation to meet your needs in different scenarios, and provides you with great convenience when collecting and organizing wires.
- 【Rubber Pad Protects Desk】Wire organizer under desk built-in soft rubber pads on the clamp protect your desk from scratches, so you will not damage your furniture or office.
- 【Sturdy and Beautiful】Cord management under desk is made of high-quality carbon steel and holds about 15 lbs. The wire basket has 2 holes on each side of the tray to enable your cables to pass freely. Cable baskets are suitable for desk thickness use from 0.4" to 2.4".
- 【Space Saving & Keep Organized】Desk cable management tray holds all your power cords, outlet strips, USB hubs and computer transformers hidden from your feet, and the data cables will not enter the vacuum cleaner to keep your desk clean and tidy. Desk wire organizer is also suitable for use in the kitchen and outdoors.
- 【Reduce Safety Risks】Cable tray under desk keeps all plugs away from your kids, no more worry about tripping. Using 2 holes wire tray saves extra space, helps you easily cabling and wire protection. The mesh design is not easy to accumulate dust, but avoids safety accidents caused by messy wires.
no-cache
A negative interval and epoch produce Cache-Control: no-cache. This does not necessarily mean “never store.” It tells a cache that the stored response must be checked with the origin before reuse.
Common mistakes and fixes
The header is missing
- Confirm the request reached the expected virtual host and location.
- Check for an earlier regular-expression location that matches first.
- Look for an included configuration file that overrides or replaces the block.
- Run
nginx -t, reload, and repeatcurl -I; an edited file has no effect until the running workers load it. - Check whether a CDN or reverse proxy is returning a cached response generated before the change.
The browser still shows an old asset
- Inspect the asset URL in the browser’s network panel. A long-lived cached response may be behaving exactly as configured.
- Use a new filename or query/build version for the changed asset.
- For emergency replacement of an unchanged URL, temporarily use a short lifetime or a negative interval, then restore the normal policy after caches have revalidated.
Two cache-control headers appear
Search the configuration for add_header Cache-Control, upstream header forwarding, and another expires directive. Remove the competing rule or make one layer authoritative. Duplicate directives can give clients inconsistent instructions.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEScan for outdated or missing drivers - takes under a minuteDriver Scan →Only some status codes have the header
That is expected when the response status is outside the directive’s supported list. Check whether the request is returning an error, an authentication response, or an application-generated status instead of the static file you intended to cache.
expires max appears too aggressive
max intentionally means ten years (315360000 seconds) and uses the fixed date 31 December 2037 23:55:55 GMT. Use it only for URLs that change when their contents change; otherwise choose a finite interval such as seven days.
Browser caching versus Nginx proxy caching
expires controls headers sent to clients and downstream caches. It is separate from Nginx’s proxy-cache storage, which has its own configuration and may use origin Expires or Cache-Control values when deciding how long an upstream response remains in that cache.
Changing a browser policy does not automatically purge an object already stored by a proxy cache. If a reverse proxy or CDN sits in front of Nginx, inspect the headers at the public hostname and follow that layer’s purge or revalidation process separately.
Production checklist
- Apply long lifetimes only to assets with versioned or content-hashed URLs.
- Use a shorter interval for files replaced at the same URL.
- Keep HTML, personalized pages, and sensitive responses out of a broad static-file location.
- Do not pair
expireswith a competing customCache-Controlheader in the same location. - Review regular-expression location order whenever a rule seems to be ignored.
- Run
nginx -tbefore every reload. - Verify with
curl -Iagainst the public URL after deployment. - Check both the status code and the generated
Cache-ControlandExpiresvalues. - Remember that
immutablerequires an explicitadd_header;expirescannot generate it.
Recommended starting configuration
For a site that uses stable filenames for some files and hashed filenames for build output, separate the policies:
server {
listen 443 ssl;
server_name example.com;
root /var/www/example;
# Build files have content-hashed names.
location /assets/ {
expires 1y;
}
# Files replaced in place get a shorter lifetime.
location ~* .(?:css|js|jpg|jpeg|png|gif|svg|webp|woff2)$ {
expires 7d;
}
}
Because overlapping regular-expression locations are order-sensitive, do not assume the second block will win if another regex also matches a path under /assets/. Test representative URLs from each directory and adjust the locations so every request reaches the intended policy.
Quick Recap
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

