logo Online Learner
  • Home
  • Learning Paths
  • Development
    Frontend Development Backend Development
  • Study Notes
  • Free Resume Builder
  • About Us
  • Contact Us
  • Login
  • Sign Up
  1. Learning Paths
  2. Next.js Tutorial
  3. Next js Caching and Revalidation

Next.js Caching & Revalidation

Next.js caching is the feature that decides whether your page is served from a fast stored copy or rebuilt from scratch on every visit. When it works, users see instant pages and your database does less work. When it goes wrong, users see old data and wonder why their changes disappeared. This tutorial focuses on the newer Cache Components model in Next.js 16, because the caching rules changed significantly from earlier versions.

You will learn how to enable Cache Components in next.config.ts, mark a function as cacheable with the 'use cache' directive, control its lifetime with cacheLife, and invalidate it on demand with cacheTag and revalidateTag. You will also see how updateTag differs from revalidateTag for read-your-own-writes, and how to avoid the stale-data mistakes that catch most beginners.

If you are new to data fetching, read Next.js Data Fetching first. Caching builds directly on how and where you fetch. The mutation side, covered in Next.js Forms & Server Actions, is where invalidation usually happens.

Version note: The code and API names in this tutorial were written for Next.js 16 with the App Router. Cache Components became the recommended model starting with Next.js 16.4, and all new apps created with create-next-app now enable it by default . If you are on an earlier version, check the official docs for the correct flag and function names.

What Is Next.js Caching with Cache Components?

Next.js caching with Cache Components is an opt-in system where you mark specific functions or components with the 'use cache' directive. Next.js stores their return value and reuses it for future requests. You control how long the cache lives with cacheLife and how to invalidate it with cacheTag .

Here is the smallest useful example. It caches a database query for one hour:

// app/lib/users.ts
import { cacheLife } from 'next/cache';

export async function getUsers() {
  'use cache';
  cacheLife('hours');

  return db.query('SELECT * FROM users');
}

Output: The first call runs the query and stores the result. Later calls within the cache lifetime return the stored result without touching the database. After the lifetime ends, the next request triggers a background refresh while serving the old result briefly.

How it works: The 'use cache' directive at the top of the function body marks the function as cacheable. Next.js creates a cache key from the function arguments and any values it reads from the parent scope. cacheLife('hours') applies a preset profile that controls how long the client can use the cached data, when the server refreshes it, and when it expires completely .

Enabling Cache Components in next.config.ts

Cache Components is not automatic in existing projects. You must enable it in next.config.ts with the cacheComponents flag .

// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  cacheComponents: true,
};

export default nextConfig;

Output: After restarting the dev server, the 'use cache' directive, cacheLife, and cacheTag become available. Without this flag, the 'use cache' directive is not recognized.

How it works: The flag tells Next.js to use the Cache Components model instead of the older fetch-based caching options. When enabled, route segment configs like dynamic, revalidate, and fetchCache are replaced by use cache and cacheLife. If your project still exports those older configs, Next.js will report an error .

Controlling Cache Lifetime with cacheLife

cacheLife sets the lifetime of a cached function or component. You can use a preset profile like 'seconds', 'minutes', 'hours', 'days', 'weeks', or 'max', or pass an object with stale, revalidate, and expire values .

// app/lib/posts.ts
import { cacheLife } from 'next/cache';

export async function getLatestPosts() {
  'use cache';
  cacheLife({
    stale: 60,
    revalidate: 300,
    expire: 3600,
  });

  return db.query('SELECT * FROM posts ORDER BY created_at DESC LIMIT 10');
}

Output: Clients can reuse the cached list for 60 seconds without checking the server. After 300 seconds, the next request triggers a background refresh. After 3600 seconds with no requests, the next request waits for fresh data.

How it works: The three values control different phases. stale is how long the client treats the data as fresh. revalidate is how often the server regenerates the cache in the background. expire is the hard limit after which stale content is no longer served and the next request blocks until fresh data is ready. The expire value must be longer than revalidate .

Tagging Cached Data with cacheTag

cacheTag assigns one or more string labels to a cached function or component. You can later invalidate every entry with that tag without knowing which functions or routes created them .

// app/lib/products.ts
import { cacheLife, cacheTag } from 'next/cache';

export async function getProducts() {
  'use cache';
  cacheLife('hours');
  cacheTag('products');

  return db.query('SELECT * FROM products');
}

Output: The product list is cached under the tag 'products'. When you call revalidateTag('products', 'max') or updateTag('products') from a Server Action, the next request for this data fetches fresh results.

How it works: Tags are case-sensitive and must be unique enough to avoid accidental collisions. You can pass multiple tags in one call: cacheTag('products', 'featured'). The same tag can be reused across many cached functions, so one invalidation refreshes all of them. Tags are idempotent; applying the same tag twice has no extra effect .

Time-Based vs On-Demand Revalidation

Revalidation is the process of updating cached data. There are two strategies: time-based, where the cache refreshes automatically after a set duration, and on-demand, where you trigger a refresh manually after a mutation .

Strategy How it works Best for API
Time-based Cache refreshes automatically after a duration Data that changes on a predictable schedule cacheLife
On-demand (stale-while-revalidate) Serves stale data briefly while fresh data loads Blog posts, product catalogs, content where a short delay is fine revalidateTag(tag, 'max')
On-demand (immediate) Expires cache immediately; next request waits for fresh data Read-your-own-writes after a user creates or updates something updateTag(tag) in Server Actions

How it works: Time-based revalidation is passive; you set it once and the cache maintains itself. On-demand revalidation is active; you call a function after a mutation. The two can be combined: use cacheLife for a baseline freshness guarantee, and revalidateTag or updateTag when you know something changed right now .

revalidateTag, updateTag, and revalidatePath

Next.js provides three on-demand functions, and choosing the right one matters for what the user sees after a mutation.

revalidateTag for stale-while-revalidate

// app/actions.ts
'use server';

import { revalidateTag } from 'next/cache';

export async function updateProduct(formData: FormData) {
  const id = formData.get('id');
  await db.query('UPDATE products SET name = $1 WHERE id = $2', [
    formData.get('name'),
    id,
  ]);

  revalidateTag('products', 'max');
}

Output: The next visitor sees the old product list briefly while Next.js regenerates it in the background. After the background refresh finishes, new visitors see fresh data.

How it works: revalidateTag marks matching entries as stale. The second argument 'max' sets a long stale window, so requests are always served stale content while revalidation runs. This is the recommended profile for content where a small delay is acceptable . If you need immediate visibility, use updateTag instead.

updateTag for read-your-own-writes

// app/actions.ts
'use server';

import { updateTag } from 'next/cache';
import { redirect } from 'next/navigation';

export async function createPost(formData: FormData) {
  const post = await db.query(
    'INSERT INTO posts (title) VALUES ($1) RETURNING id',
    [formData.get('title')]
  );

  updateTag('posts');
  redirect(`/posts/${post.id}`);
}

Output: The user who created the post is redirected to the new post and sees fresh data immediately. The cache is expired synchronously, not in the background.

How it works: updateTag can only be called inside a Server Action. It immediately expires the cache for the tag and refreshes the calling route. Use it when the user must see their own change right away, such as after submitting a form or creating a resource . For webhooks and Route Handlers, use revalidateTag instead.

revalidatePath for path-based invalidation

// app/actions.ts
'use server';

import { revalidatePath } from 'next/cache';

export async function updateSettings(formData: FormData) {
  await db.query('UPDATE settings SET theme = $1', [formData.get('theme')]);
  revalidatePath('/settings');
}

Output: The /settings page cache is invalidated. The next visit renders with fresh data.

How it works: revalidatePath takes a path string and an optional type of 'page' or 'layout'. For dynamic routes, pass the route pattern and 'page': revalidatePath('/posts/[slug]', 'page'). Prefer tag-based invalidation when possible, because it is more precise and avoids refreshing pages that did not change .

Common Mistakes and Best Practices

  • Caching user-specific data under a global tag. If getUserProfile() is cached with the tag 'profile' and no user ID in the cache key, one user's profile can be served to another. Include user-specific values as function arguments so they become part of the cache key, or avoid caching personalized data entirely.
  • Forgetting that updateTag only works in Server Actions. Calling updateTag from a Route Handler throws the error updateTag can only be called from within a Server Action. Use revalidateTag in Route Handlers and webhooks .
  • Using revalidateTag when the user must see their change immediately. With the 'max' profile, revalidateTag serves stale data while refreshing. If the user just submitted a form, they will see old data. Use updateTag in Server Actions for read-your-own-writes.
  • Mixing Cache Components with old route configs. When cacheComponents: true is set, exporting dynamic, revalidate, or fetchCache from a route segment causes an error. Remove the old configs and use use cache with cacheLife instead .
  • Caching without a cacheLife call. Next.js applies an implicit default profile, but it is better to be explicit. Pair every 'use cache' with a cacheLife call so you know exactly how long the data lives .

Real-World Example: A Cached Product List with Invalidation

This example combines 'use cache', cacheLife, cacheTag, and a Server Action that invalidates the cache after creating a product.

// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  cacheComponents: true,
};

export default nextConfig;
// app/lib/products.ts
import { cacheLife, cacheTag } from 'next/cache';

export type Product = {
  id: number;
  name: string;
  price: number;
};

export async function getProducts(): Promise<Product[]> {
  'use cache';
  cacheLife('hours');
  cacheTag('products');

  const result = await db.query('SELECT id, name, price FROM products');
  return result as Product[];
}
// app/actions.ts
'use server';

import { updateTag } from 'next/cache';
import { revalidatePath } from 'next/cache';

export async function addProduct(formData: FormData) {
  const name = formData.get('name');
  const price = formData.get('price');

  if (typeof name !== 'string' || name.trim().length === 0) {
    return { error: 'Name is required' };
  }

  await db.query('INSERT INTO products (name, price) VALUES ($1, $2)', [
    name.trim(),
    Number(price),
  ]);

  updateTag('products');
  revalidatePath('/products');
}

Line-by-line explanation:

  • next.config.ts enables Cache Components. Without this, the 'use cache' directive is ignored.
  • getProducts is marked with 'use cache' and tagged 'products'. The result is cached for the 'hours' profile.
  • addProduct is a Server Action. It validates the name, inserts the product, and calls updateTag('products').
  • updateTag immediately expires every cached entry tagged 'products'. The next call to getProducts fetches fresh data.
  • revalidatePath('/products') also refreshes the page route, so the user who submitted the form sees the new product without a manual reload.

If you need stale-while-revalidate instead of immediate expiration, replace updateTag('products') with revalidateTag('products', 'max'). That is better for background jobs or webhooks where a short delay is acceptable.

Summary

  • Next.js caching with Cache Components is opt-in. Enable cacheComponents: true in next.config.ts and mark cacheable functions with 'use cache'.
  • cacheLife controls cache duration with profiles or explicit stale, revalidate, and expire values.
  • cacheTag labels cache entries so you can invalidate them later without knowing which functions created them.
  • Use revalidateTag(tag, 'max') for stale-while-revalidate. Use updateTag(tag) in Server Actions when the user must see their change immediately.
  • revalidatePath invalidates a specific route. Prefer tag-based invalidation when possible for precision.
  • Always include user-specific values in function arguments so they become part of the cache key and do not leak between users.

Now that your data is cached and fresh, the next step is making your images load just as fast. Continue with Next.js Image Optimization.

Frequently Asked Questions

Do I need to enable Cache Components to use use cache?

Yes. The 'use cache' directive is part of the Cache Components model, which requires cacheComponents: true in next.config.ts. Without the flag, Next.js does not recognize the directive and your functions run uncached. New projects created with create-next-app in recent versions have it enabled by default.

What is the difference between revalidateTag and updateTag?

revalidateTag marks cache entries as stale and serves old data while fresh data loads in the background. updateTag immediately expires the cache and makes the next request wait for fresh data. Use updateTag in Server Actions when a user must see their own change right away. Use revalidateTag for webhooks and background refreshes.

Can I call revalidateTag from a Client Component?

No. revalidateTag only works on the server. It can be called from Server Actions and Route Handlers, but not from Client Components or Proxy. If you need to trigger invalidation from the client, call a Server Action that runs revalidateTag or updateTag for you.

What happens if I cache data without calling cacheLife?

Next.js applies an implicit default profile. The data still gets a cache lifetime, but you do not control how long it lives or when it refreshes. For predictable behavior, always call cacheLife inside the cached function. This makes the cache duration explicit and easy to reason about when debugging stale data.

Why does my page still show old data after a mutation?

The page or data function is likely still cached and has not been invalidated. Check that you called updateTag or revalidateTag with the correct tag after the mutation. Also verify that the tag on the cached function matches the tag you invalidated. If you used revalidateTag with the 'max' profile, stale data is served briefly while the refresh happens in the background.

Practice Exercises

Easy: Enable Cache Components

Add the Cache Components flag to a next.config.ts file. Then create a cached function that returns a static list of three names and log the result.

Show solution
// next.config.ts
import type { NextConfig } from 'next';

const nextConfig: NextConfig = {
  cacheComponents: true,
};

export default nextConfig;
// app/lib/names.ts
import { cacheLife } from 'next/cache';

export async function getNames() {
  'use cache';
  cacheLife('hours');
  return ['Asha', 'Ravi', 'Meera'];
}

The flag makes 'use cache' available, and cacheLife('hours') sets the cache duration.

Easy: Tag a cached function

Add the tag 'team' to the getNames function from the previous exercise.

Show solution
// app/lib/names.ts
import { cacheLife, cacheTag } from 'next/cache';

export async function getNames() {
  'use cache';
  cacheLife('hours');
  cacheTag('team');
  return ['Asha', 'Ravi', 'Meera'];
}

cacheTag('team') labels the cache entry so it can be invalidated later with updateTag('team') or revalidateTag('team', 'max').

Medium: Invalidate a tag from a Server Action

Write a Server Action that adds a name to a database (simulated with a log) and immediately invalidates the 'team' tag with updateTag.

Show solution
// app/actions.ts
'use server';

import { updateTag } from 'next/cache';

export async function addName(formData: FormData) {
  const name = formData.get('name');

  if (typeof name !== 'string' || name.trim().length === 0) {
    return { error: 'Name is required' };
  }

  console.log('Adding name:', name.trim());
  updateTag('team');
}

updateTag('team') expires the cache immediately, so the next call to getNames fetches fresh data.

Challenge: Use revalidateTag for a webhook-style refresh

Create a Route Handler that accepts a tag as a query parameter and calls revalidateTag with the 'max' profile.

Show solution
// app/api/revalidate/route.ts
import { revalidateTag } from 'next/cache';
import { type NextRequest } from 'next/server';

export async function GET(request: NextRequest) {
  const tag = request.nextUrl.searchParams.get('tag');

  if (!tag) {
    return Response.json({ error: 'Missing tag' }, { status: 400 });
  }

  revalidateTag(tag, 'max');
  return Response.json({ revalidated: true, tag });
}

revalidateTag works in Route Handlers, unlike updateTag. The 'max' profile serves stale content while the refresh happens in the background.



Shaikh Abdul Shahid
Written by Shaikh Abdul Shahid

A Full-Stack Developer with experience in PHP, Laravel, JavaScript, and React.
Founder of Online Learner, sharing practical knowledge and programming tutorials.
Building and maintaining real-world web applications since 2017.

GitLab LinkedIn
X
0 likes
Your Feedback

Help us improve by sharing your thoughts.

IT and Digital Marketing
keyboard_arrow_left Previous
Next keyboard_arrow_right
Online Learner Logo

Online Learner helps developers master programming, database concepts, interview preparation, and real-world implementation through structured learning paths.

Quick Links

  • Frontend Development
  • Backend Development
  • Learning Paths
  • Notes
  • Free Resume Builder
  • Portfolio

Company

  • About Us
  • Contact Us
  • Terms & Conditions
  • Disclaimer

© 2023 - 2026 OnlineLearner.in | All Rights Reserved.

logo
  • code Frontend
  • storage Backend
  • live_help Interviews
  • work_outline PHP Frameworks
  • settings Routine Use
  • book Blogs
Frontend
  • HTML Tutorial
    • HTML Introduction
    • HTML Tags
    • HTML Elements
    • HTML Attributes
    • HTML Heading
    • HTML Paragraph
    • HTML Formatting
    • HTML Quotations
    • HTML Comments
    • HTML Styles
    • HTML Color
    • HTML CSS
    • HTML Images
    • HTML Favicon
    • HTML Links
    • HTML DIV
    • HTML Tables
    • HTML Table Size
    • HTML Table Head
    • Table Padding & Spa...
    • Table colspan rowspsn
    • HTML Table Styling
    • HTML Colgroup
    • HTML List
    • HTML Block & Inline
    • HTML Classes
    • HTML Id
    • HTML Iframes
    • HTML Head
    • HTML Layout
    • HTML Semantic Elements
    • HTML Style Guide
    • HTML Forms
    • HTML Form Attribute
    • HTML Form Element
    • HTML input type
    • HTML Computer code
    • HTML Entity
    • HTML Symbol
    • HTML Emojis
    • HTML Charset
    • HTML Input Form Att...
    • HTML URL Encoding
  • CSS Tutorial
    • CSS Introduction
    • CSS Syntax
    • CSS Selector
    • How To Add CSS
    • CSS Comments
    • CSS Colors
    • CSS Background color
    • CSS background-image
    • CSS Borders
    • CSS Margins
    • CSS Height, Width a...
    • CSS Box Model
    • CSS Outline
    • CSS Text
    • CSS Fonts
    • CSS Icon
    • CSS Links
    • CSS Tables
    • CSS Display
    • CSS Maximum Width
    • CSS Position
    • z-index Property
  • JavaScript Tutorial
    • What is JavaScript
    • JS Syntax
    • JS Variables
    • JS Data Types
    • JS Operators
    • JS Control Flow - IF
    • JS Control Flow - S...
    • JS Control Flow - Loop
    • JS Function
    • JS Object Methods
    • JS Anonymous Funct...
    • JS Recursive Function
    • JS Default Parameters
    • JS this Keyword
    • What is an Array in...
    • What are JavaScript...
    • Error Handling in J...
    • DOM Selection in Ja...
    • DOM Traversal in Ja...
    • Manipulating Elemen...
    • Event Handling in J...
    • JavaScript Event Li...
    • JavaScript Event Pr...
    • Form Handling in Ja...
    • Dynamic Styling in ...
    • JavaScript DOM Elem...
    • Window Object in Ja...
    • What is Local Storage?
    • Regular Expressions...
  • Jquery Tutorial
    • What is jQuery?
    • Benefits of using j...
    • Include jQuery
    • Selectors.
    • Methods.
    • The $ symbol and sh...
    • Selecting elements
    • Getting and setting...
    • Adding and removing...
    • Modifying CSS and c...
    • Binding and Unbindi...
    • Common events: clic...
    • Event delegation
    • Using .on() for dyn...
    • Showing and hiding ...
    • Fading elements in ...
    • Sliding elements up...
    • .animate()
    • Understanding AJAX
    • .ajax()
    • .load(), .get(), .p...
    • Handling responses ...
    • Parent
    • Chlid
    • Siblings
    • Filtering Elements
    • Using find
    • Selecting form elem...
    • Getting form values
    • Setting form values
    • Form validation
    • Handling form submi...
    • jQuery plugins
    • Sliders plugins
    • $.each()
    • $.trim()
    • $.extend()
    • Data attributes
    • Debugging jQuery code
  • Bootstrap 4
    • What is Bootstrap
    • Benefits of using
    • Setting up
    • Container
    • Row and Column
    • Grid Classes
    • Breakpoints
    • Offsetting Columns
    • Column Ordering
    • Basic Typography
    • Text Alignment
    • Text colors
    • Backgrounds
    • Display
    • Font Size Utilities
    • Buttons
    • Navs and Navbar
    • Forms
    • Cards
    • Alerts
    • Badges
    • Progress Bars
    • Margin
    • Padding
    • Sizing
    • Flexbox
    • Dropdowns
    • Modals
    • Tooltips
    • Popovers
    • Collapse
    • Carousel
    • Images
    • Tables
    • Jumbotron
    • Media Object
  • Git
    • Understanding Versi...
    • Download and Instal...
    • Git Configure
    • Git Initialize
    • Add Changes to Staging
    • Commit Changes
    • Branching
    • Merging
    • Remote Repository
    • Understanding Git C...
    • Stashing Changes
    • Viewing Commit History
    • Undoing Changes
  • Ajax Tutorial
    • Ajax Fundamentals
    • Ajax Working
    • XMLHttpRequest Fetch
    • Synchronous vs Asyn...
    • Ajax Advantages
    • Ajax Disadvantages
    • $.ajax() method
    • Ajax GET request
    • Ajax POST Request
    • Json Response
    • Ajax Errors
    • Ajax Form
  • React Tutorial
    • What is React? Begi...
    • React Environment S...
    • React Fundamentals:...
    • Functional vs Class...
    • Props in React Expl...
    • State and setState ...
    • React Event Handling
    • React Conditional R...
    • React Lists and Keys
    • Styling in React In...
    • Styling in React Us...
    • Styling in React Us...
    • Tailwind CSS with R...
    • Tailwind vs CSS Mod...
    • React Hooks
    • React useState Hook
    • React useEffect Hook
    • React useRef Hook
    • React useContext Hook
    • React useReducer Hook
    • Custom Hooks in React
    • React Router – In...
    • Installing React Ro...
    • React Router – Ro...
    • React Router – Ne...
    • React Router URL Pa...
    • React Router Protec...
    • React Router Redire...
    • State Management in...
    • Redux State Managem...
    • Redux Toolkit Expla...
    • Redux Toolkit vs Re...
    • Controlled vs Uncon...
    • Handling Form Input...
    • API Integration in ...
    • Axios in React – ...
    • Handling Loading an...
    • Async Await in Java...
    • Displaying API Data...
    • CRUD Operations in ...
    • React Performance O...
    • React Performance O...
  • Tailwind
    • Introduction to Tai...
    • Utility-First CSS E...
    • Tailwind CSS vs Boo...
    • When and Why to Use...
    • Real-World Use Case...
    • Tailwind CSS Instal...
    • Installing Tailwind...
    • Tailwind CSS with V...
    • Setting Up Tailwind...
    • Install Tailwind CS...
    • Tailwind CSS Colors...
    • Tailwind CSS Backgr...
    • Tailwind CSS Paddin...
    • Tailwind CSS Margin...
    • Tailwind CSS Width ...
    • Tailwind CSS Height...
    • Tailwind CSS Border...
    • Tailwind CSS Border...
    • Tailwind CSS Text S...
    • Tailwind CSS Box Sh...
    • Tailwind CSS Opacit...
    • Tailwind CSS Cursor...
    • Tailwind CSS Overfl...
    • Tailwind CSS Font S...
    • Tailwind CSS Font W...
    • Tailwind CSS Text A...
    • Tailwind CSS Line H...
    • Tailwind CSS Letter...
    • Tailwind CSS Text T...
    • How to Use Google F...
    • Flexbox with Tailwi...
    • Justify Content in ...
    • Align Items in Tail...
    • Flex Direction in T...
    • Gap in Tailwind CSS...
    • Flexbox with Tailwi...
    • Grid System in Tail...
    • Grid System in Tail...
    • Responsive Design i...
    • Positioning & Z-Ind...
    • Background Colors i...
    • Background Images i...
    • Gradients in Tailwi...
    • Image Object-Fit in...
    • Image Overlay Effec...
    • Buttons in Tailwind...
    • Hover & Focus State...
    • Buttons and Forms i...
    • Cards and Sections ...
    • Navbar and Footer D...
  • TypeScript Tutorial
    • TypeScript Introduc...
    • TypeScript Installa...
    • First TypeScript Pr...
    • TypeScript Basic Types
    • Type Inference and ...
    • TypeScript Arrays a...
    • TypeScript Enums
    • TypeScript Any, Unk...
    • TypeScript Interfaces
    • Type Aliases and Un...
    • Intersection Types
    • Literal Types
    • Functions in TypeSc...
    • Classes in TypeScript
    • Access Modifiers an...
    • Abstract Classes
    • TypeScript Generics
    • TypeScript Utility ...
    • Type Guards and Nar...
    • Modules and Namespaces
    • TypeScript Decorators
    • TypeScript with React
    • TypeScript with Nod...
  • Next.js Tutorial
    • Introduction to Nex...
    • Next js Setup and P...
    • Next js App Router ...
    • Next js Pages and L...
    • Next js Navigation ...
    • Next js Dynamic Routes
    • Next js Route Groups
    • Next js Middleware
    • Server vs Client Co...
    • SSR, SSG and ISR Ex...
    • Next js Loading and...
    • Next js Data Fetching
    • Next js Route Handl...
    • Next js Forms and S...
    • Next js Caching and...
    • Next js Image Optim...
    • Next js Metadata an...
    • Tailwind CSS with N...
    • Next js Authentication
    • Next js Database wi...
Backend
  • PHP Tutorial
    • PHP Introduction
    • PHP Installation
    • PHP Syntax
    • PHP Comments
    • PHP Variable
    • PHP Echo
    • PHP Data Types
    • PHP Strings
    • PHP Constant
    • PHP Maths
    • PHP Number
    • PHP Operators
    • PHP if else & if el...
    • PHP Switch
    • PHP Loops
    • PHP Functions
    • PHP Array
    • PHP OOps
    • PHP Class & Object
    • PHP Constructor
    • PHP Destructor
    • PHP Access Modfiers
    • PHP Inheritance
    • PHP Final Keyword
    • PHP Class Constant
    • PHP Abstract Class
    • PHP Superglobals
    • PHP Regular Expression
    • PHP Interfaces
    • PHP Static Method
    • PHP Static Properties
    • PHP Namespace
    • PHP Iterable
    • PHP Form Introduction
    • PHP Form Validation
    • PHP Complete Form
    • PHP Date and Time
    • PHP Include Files
    • PHP - Files & I/O
    • File Upload
    • PHP Cookies
    • PHP SESSION
    • PHP Filters
    • PHP Callback Functions
    • PHP JSON
    • PHP AND Exceptions
    • PHP Connect database
  • PHP Functions
    • strlen
    • strtoupper
    • strtolower
    • ucfirst
    • ucwords
    • substr
    • str_replace
    • strpos
    • trim in php
    • explode
    • implode
    • count in php
    • array_merge
    • array_push
    • array_pop
    • array_shift
    • array_unshift
    • in_array
    • array_keys
    • array_values
    • array_filter
    • array_map
    • sort
    • asort
    • ksort
    • abs
    • round
    • ceil
    • floor
    • rand
    • mt_rand
    • max
    • min
    • pow
    • sqrt
    • date
    • time
    • strtotime
    • mktime
    • date_diff
    • getdate
    • fopen
    • fread
    • fwrite
    • fclose
    • file_get_contents
    • file_put_contents
    • file_exists
    • unlink
    • filesize
    • is_readable
    • is_writable
    • urlencode
    • urldecode
    • parse_url
    • http_build_query
    • isset
    • empty
    • is_numeric
    • is_array
    • is_string
    • filter_var
    • htmlspecialchars
    • md5
    • sha1
    • password_hash
    • password_verify
    • die
    • exit
    • var_dump
    • print_r
    • include
    • require
    • json_encode
    • json_decode
    • sleep
  • PHP and MySQL Functions
    • mysqli_connect
    • mysqli_select_db
    • mysqli_query
    • mysqli_prepare
    • mysqli_stmt_execute
    • mysqli_multi_query
    • mysqli_fetch_assoc
    • mysqli_fetch_array
    • mysqli_fetch_row
    • mysqli_fetch_object
    • mysqli_num_rows
    • mysqli_real_escape_...
    • mysqli_insert_id
    • mysqli_affected_rows
    • mysqli_error
    • mysqli_close
    • mysqli_commit
    • mysqli_rollback
  • Python Tutorial
    • What is Python?
    • Install Python on W...
    • Install Python on L...
    • Install Python on m...
    • IDE Setup
    • Python syntax
    • Python Comments
    • Python Indentation
    • Python Variables
    • Python Data Types
    • Python Numeric
    • Python Boolean
    • Python String
    • Python List
    • Python Tuple
    • Python Range
    • Python Dictionary
    • Python Arithmetic O...
    • Python Assignment O...
    • Python Comparison O...
    • Python Logical Oper...
    • Python Bitwise Oper...
    • Python if condition
    • Python if else cond...
    • Python For Loop
    • Python While Loop
    • Python break, conti...
  • MYSQL
    • SQL Introduction
    • Syntax
    • Select statement
    • Select Distinct
    • WHERE Clause
    • Order By
    • SQL AND Operator
    • SQL OR Operator
    • SQL NOT Operator
    • SQL LIKE
    • SQL IN
    • SQL BETWEEN
    • SQL INSERT INTO
    • SQL NULL Values
    • SQL UPDATE
    • SQL DELETE
    • SQL TOP, LIMIT, FET...
    • SQL MIN() and MAX()...
    • SQL COUNT() Function
    • SQL SUM()
    • SQL AVG()
    • SQL Aliases
    • SQL JOIN
    • SQL INNER JOIN
    • SQL LEFT JOIN
    • SQL RIGHT JOIN
    • SQL FULL OUTER JOIN
    • SQL Self Join
    • SQL UNION
    • SQL GROUP BY
    • SQL HAVING
    • SQL EXISTS
    • SQL ANY and ALL
    • SQL SELECT INTO
    • SQL INSERT INTO SELECT
    • SQL CASE
    • SQL NULL Functions
    • SQL Stored Procedures
    • SQL Comments
    • SQL Operators
    • SQL CREATE DATABASE
    • SQL DROP DATABASE
    • SQL BACKUP DATABASE
    • SQL CREATE TABLE
    • SQL DROP TABLE
    • SQL ALTER TABLE
    • SQL Constraints
    • SQL NOT NULL
    • SQL UNIQUE Constraint
    • SQL PRIMARY KEY
    • SQL FOREIGN KEY
    • SQL CHECK Constraint
    • SQL CREATE INDEX
    • SQL AUTO INCREMENT
    • SQL Dates
    • SQL Views
    • SQL Injection
    • SQL Hosting
    • SQL Data Types
  • Node Js
    • What is Node.js?
    • Why use Node.js?
    • Installing Node.js
    • First Node.js progr...
    • Event Loop
    • Understanding npm
    • What are Modules?
    • fs (File System)
    • Http Module
    • Path Module
    • Creating custom mod...
    • Exporting and impor...
    • Setting up a basic ...
    • Handling requests a...
    • Serving HTML
    • Serving CSS
    • Serving JavaScript
  • Python MySQL
    • Database Connection
    • Table Creation
    • Insert Query
    • Select Query
    • Update Query
    • Delete Query
    • Where Clause Query
    • Limit Clause Query
    • Join Tables
    • Order By Query
    • Group By Query
    • Aggregate Functions
    • Parameterized Query
  • Java Tutorials
    • Java Introduction
    • Java Installation
    • Java Syntax
    • Java Comments
    • Java Variables
    • Java DataTypes
    • Java Operators
    • Java Conditionals
    • Java Looping
    • Java Arrays
    • Java Methods
    • Java Classes
    • Java Objects
    • Java Constructors
    • Java Inheritance
    • Java Polymorphism
    • Java Encapsulation
    • Java Abstraction
    • Java Exception
    • Java Interfaces
    • Java File Handling
    • Java Threads
    • Java Access Modifiers
    • Java Static Keyword
    • Java Final Keyword
    • Java Nested Class
    • Java Synchronization
  • Docker
    • Introduction to Docker
    • Installing Docker
    • Docker Architecture
    • Docker Images
    • Docker Containers
    • Dockerfile Basics
    • Docker Volumes
    • Docker Networking
    • Docker Compose
    • Docker Hub & Registry
    • Multi-Stage Builds
    • Docker with Nginx
    • Docker with MySQL
    • Docker with PHP & L...
    • Docker Environment ...
    • Docker Logs & Debug...
    • Docker Security Bes...
    • Docker Swarm Basics
    • Docker vs Virtual M...
    • Real World Docker P...
Interviews
  • PHP Interviews
    • What is PHP?
    • What does PHP stand...
    • PHP Advantages
    • Difference between ...
    • Start a PHP script?
    • Commenting in PHP
    • Variable in PHP
    • Different types of ...
    • Different types of ...
    • Array in PHP
    • Difference between ...
    • Retrieve data from ...
    • PHP handle errors
    • Sessions in PHP
    • PHP Cookie
    • What are the main f...
    • What are the differ...
    • What are the differ...
  • Java Interview Questions
    • Java Basics – Wha...
    • What is the differe...
    • What are the OOP co...
    • Why is the main met...
    • What are the differ...
    • What is the differe...
    • What is Method Over...
    • What is the Differe...
    • What is the Constru...
    • What are the Access...
    • What is the this Ke...
    • What is the super K...
    • What is the static ...
    • What is the final K...
    • What is Exception H...
    • What are Checked an...
    • What is the Differe...
    • What are Multithrea...
    • What is the Java Co...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • What is the Differe...
    • How Does HashMap Wo...
    • What is the Differe...
    • What is the Differe...
    • What is the String ...
    • What is the Differe...
    • What is Garbage Col...
    • What is the Differe...
    • What is a Lambda Ex...
    • What is the Stream ...
    • What are Optional C...
    • What is the Differe...
    • What are the Key Fe...
    • What is the Record ...
  • React Interviews
    • What is React.js
    • Help In Interviews
    • Features of React
    • What is JSX
    • React's Virtual DOM
    • State and Props
    • React handle data b...
    • React Component
    • setState() method.
    • Controlled Components
    • Lifecycle Methods
    • Significance of keys
    • What are the differ...
  • Laravel Interviews
    • What is Laravel?
    • What are the key fe...
    • Explain the concept...
    • What is a controlle...
    • What is Blade templ...
    • How does Eloquent O...
    • Explain the concept...
    • What are middleware...
    • How do you create a...
    • What is CSRF protec...
    • What is the purpose...
    • What is the purpose...
    • Explain the concept...
    • How do you create a...
    • What is the purpose...
    • How do you define r...
    • What are named rout...
    • Explain the use of ...
    • What is the purpose...
    • What are service pr...
  • SQL Interviews
    • What is SQL?
    • What are the differ...
    • What is the differe...
    • What is a primary key?
    • What is a foreign key?
    • What are the differ...
    • What is the differe...
    • What is the use of ...
    • What is the differe...
    • What is an index in...
    • What types of index...
    • What is a subquery?
    • How do you use the ...
    • How can you find th...
    • Explain the use of ...
    • What is a view?
    • What are the limita...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to co...
    • Write a query to fe...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to re...
    • Write a query to ge...
    • Write a query to ge...
    • Write a query to li...
    • Write a query to fi...
    • Write a query to fi...
    • Write a query to ge...
    • Write a query to fi...
    • Write a query to co...
    • Write a query to fi...
    • Write a query to li...
    • Write a query to fe...
    • Write a query to fi...
    • Write a query to fe...
    • Write a query to ge...
    • Write a query to co...
    • Write a query to fe...
  • JavaScript Interview Questions
    • What Exactly is Jav...
    • What are the data t...
    • What is the differe...
    • JavaScript double e...
    • What is a Closure i...
    • What is Hoisting in...
    • Understanding "this...
    • What Are JavaScript...
    • Null vs Undefined i...
    • How Does JavaScript...
    • What is a Promise i...
    • Async/Await in Java...
    • Event Delegation in...
    • JavaScript Modules ...
    • How to Prevent a Fu...
    • JavaScript Intervie...
    • JavaScript Intervie...
    • What is bind() in J...
    • Event Bubbling vs. ...
    • Deep Copy vs Shallo...
    • What is the new Key...
PHP Frameworks
  • Laravel
    • Laravel Topics
    • Laravel 7 Installation
    • Install laravel 8
    • Laravel 8 Routing
    • Laravel Controllers
    • Views and Blade lar...
    • Database and Eloque...
    • Authentication and ...
    • CSRF Protection
    • Laravel Model
    • Database: Query Bui...
Routine Use
  • Linux
    • How to Delete a Fil...
    • Install lemp in ubu...
    • How to check packag...
    • Navigating the File...
    • Managing Files and ...
    • Viewing and Editing...
    • Managing Processes ...
    • Scheduling Tasks wi...
    • Disk Usage Analysis...
    • File and Directory ...
Blogs
  • Blogs
    • Free Hosting on AWS...
    • PHP 8.6 Partial Fun...
    • What is SEO?
    • Zoho Free Mail
    • Speed Up Your Appli...
    • What is a JavaScrip...
    • Laravel vs Lumen: T...
    • MySQL vs PostgreSQL...
    • Automate Free MySQL...
    • How to Use Google A...
    • What is n8n?
    • Cloud Platform Comp...
    • Top Common Mistakes...
    • PHP 8.5: The Pipeli...
    • Google Antigravity ...
    • How to Optimize Que...
    • React vs Angular vs...
    • Base44: Features, P...
    • Difference Between ...
    • HTTP Status Codes E...
    • Build Native Mobile...
    • Top 10 JavaScript F...
    • JIRA, Waterfall, an...
    • WebSockets in Moder...
    • A Complete Real-Wor...
    • Why Developers Shou...
    • Service-Based Compa...
    • Bootstrap vs Tailwi...
    • Direct Prompt vs St...
    • Top 25 SEO HTML Tag...
    • Docker Commands Che...
    • Authentication vs A...
    • Top AI Portals in 2...
    • What is Replit? Com...
    • Laravel 13 Released...
    • NEET Paper Leak Pre...