304 Not Modified
You already have the latest version of this file in your browser cache. I’m not going to send it again.
When and Why to Use It
Section titled “When and Why to Use It”Use this for massive performance gains. If the client asks ‘Has this image changed since yesterday?’ and it hasn’t, respond with 304 instead of sending the heavy image again.
Usage Examples
Section titled “Usage Examples”import { HttpCode, get } from 'shokupan';
export const getResource = get('/resource', () => { return { message: 'Not Modified' };}).pipe(HttpCode(304));import { Controller, Get, HttpCode } from 'shokupan';
@Controller('/api')export class ExampleController { @Get('/resource') @HttpCode(304) getResource() { return { message: 'Not Modified' }; }}import express from 'express';const app = express();
app.get('/resource', (req, res) => { res.status(304).json({ message: 'Not Modified' });});import { Controller, Get, HttpCode } from '@nestjs/common';
@Controller('api')export class ExampleController { @Get('resource') @HttpCode(304) getResource() { return { message: 'Not Modified' }; }}import Koa from 'koa';const app = new Koa();
app.use(async ctx => { if (ctx.path === '/resource' && ctx.method === 'GET') { ctx.status = 304; ctx.body = { message: 'Not Modified' }; }});