Skip to content

Commit

Permalink
[ACA-4202] - forcing firefox to ignore cache when document version ha… (
Browse files Browse the repository at this point in the history
#6807)

* [ACA-4202] - forcing firefox to ignore cache when document version has changed

* fxed lint
  • Loading branch information
VitoAlbano authored and Thomas Hunter committed Apr 9, 2021
1 parent 723ccaf commit 3e60f16
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/core/viewer/components/pdf-viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,9 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
@Input()
thumbnailsTemplate: TemplateRef<any> = null;

@Input()
cacheType: string = '';

@Output()
rendered = new EventEmitter<any>();

Expand Down Expand Up @@ -161,6 +164,11 @@ export class PdfViewerComponent implements OnChanges, OnDestroy {
url: urlFile.currentValue,
withCredentials: this.appConfigService.get<boolean>('auth.withCredentials', undefined)
};
if (this.cacheType) {
pdfSource.httpHeaders = {
'Cache-Control': this.cacheType
};
}
this.executePdf(pdfSource);
}

Expand Down
1 change: 1 addition & 0 deletions lib/core/viewer/components/viewer.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,7 @@ <h2>{{ 'ADF_VIEWER.LOADING' | translate }}</h2>
[blobFile]="blobFile"
[urlFile]="urlFileContent"
[nameFile]="displayName"
[cacheType]="cacheTypeForContent"
(error)="onUnsupportedFile()"></adf-pdf-viewer>
</ng-container>

Expand Down
3 changes: 3 additions & 0 deletions lib/core/viewer/components/viewer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {
viewerExtensions: Array<ViewerExtensionRef> = [];

private cacheBusterNumber;
cacheTypeForContent = '';

// Extensions that are supported by the Viewer without conversion
private extensions = {
Expand Down Expand Up @@ -278,6 +279,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {

this.closeOverlayManager();
this.loadExtensions();
this.cacheTypeForContent = '';
}

private loadExtensions() {
Expand All @@ -299,6 +301,7 @@ export class ViewerComponent implements OnChanges, OnInit, OnDestroy {

private onNodeUpdated(node: Node) {
if (node && node.id === this.nodeId) {
this.cacheTypeForContent = 'no-cache';
this.generateCacheBusterNumber();
this.isLoading = true;
this.setUpNodeFile(node).then(() => {
Expand Down

0 comments on commit 3e60f16

Please sign in to comment.