Skip to content

Commit

Permalink
Disable cache and remove any server side logic. (#48)
Browse files Browse the repository at this point in the history
  • Loading branch information
skrustev authored Jan 30, 2025
1 parent 6a30459 commit f7cd816
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 70 deletions.
5 changes: 0 additions & 5 deletions angular.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@
"styles": [
"src/styles.scss"
],
"server": "src/main.server.ts",
"outputMode": "static",
"ssr": {
"entry": "src/server.ts"
},
"stylePreprocessorOptions": {
"includePaths": [
"node_modules"
Expand Down
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,10 @@
"build:fin": "ng build finance-grid",
"build:hr": "ng build hr-portal",
"build:sales": "ng build sales-grid",
"ssr": "node dist/grid-demos/server/server.mjs",
"ssr:erp": "node dist/erp-hgrid/server/server.mjs",
"ssr:fin": "node dist/finance-grid/server/server.mjs",
"ssr:hr": "node dist/hr-portal/server/server.mjs",
"ssr:sales": "node dist/sales-grid/server/server.mjs",
"ssr:fleet": "node dist/fleet-management/server/server.mjs"
"ssr:sales": "node dist/sales-grid/server/server.mjs"
},
"private": true,
"dependencies": {
Expand Down
14 changes: 0 additions & 14 deletions src/app/app.config.server.ts

This file was deleted.

8 changes: 4 additions & 4 deletions src/app/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { ApplicationConfig, provideZoneChangeDetection } from '@angular/core';
import { provideRouter } from '@angular/router';

import { routes } from './app.routes';
import { provideClientHydration, withEventReplay } from '@angular/platform-browser';
import { provideAnimations } from "@angular/platform-browser/animations";
import { provideHttpClient } from '@angular/common/http';
import { provideHttpClient, withInterceptors } from '@angular/common/http';
import { cacheInterceptor } from './cache.interceptor';


export const appConfig: ApplicationConfig = {
providers: [
provideHttpClient(),
provideHttpClient(withInterceptors([cacheInterceptor]),),
provideZoneChangeDetection({ eventCoalescing: true, runCoalescing: true }),
provideRouter(routes),
provideClientHydration(withEventReplay()),
provideAnimations()]
};
27 changes: 0 additions & 27 deletions src/app/app.routes.server.ts

This file was deleted.

9 changes: 9 additions & 0 deletions src/app/cache.interceptor.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import { HttpInterceptorFn } from "@angular/common/http";

export const cacheInterceptor: HttpInterceptorFn = (req, next) => {
req = req.clone({
headers: req.headers.set('Cache-Control', 'no-store, no-cache, must-revalidate'),
});

return next(req)
}
3 changes: 3 additions & 0 deletions src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@
<meta charset="utf-8">
<title>GridDemos</title>
<base href="/">
<meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Expires" content="0">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
Expand Down
7 changes: 0 additions & 7 deletions src/main.server.ts

This file was deleted.

5 changes: 1 addition & 4 deletions tsconfig.app.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,10 @@
"compilerOptions": {
"outDir": "./out-tsc/app",
"types": [
"node"
]
},
"files": [
"src/main.ts",
"src/main.server.ts",
"src/server.ts"
"src/main.ts"
],
"include": [
"src/**/*.d.ts"
Expand Down
23 changes: 17 additions & 6 deletions web.config
Original file line number Diff line number Diff line change
@@ -1,8 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<!-- Static content compression and caching -->
<staticContent>
<clientCache cacheControlMode="UseMaxAge" cacheControlMaxAge="7.00:00:00" />
</staticContent>
</system.webServer>

<system.webServer>
<rewrite>
<rules>
<rule name="Angular Routes" stopProcessing="true">
<match url=".*" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="./index.html" />
</rule>
</rules>
</rewrite>
</system.webServer>

</configuration>

0 comments on commit f7cd816

Please sign in to comment.