Add no-cache headers to prevent aggressive browser caching of assets

This commit is contained in:
= 2021-04-29 21:07:05 +10:00
parent 9cb2fa4263
commit 460e0afb39
8 changed files with 15 additions and 12 deletions

View File

@ -1,6 +1,9 @@
# Release notes # Release notes
## [Unreleased (daily channel)](https://github.com/invoiceninja/invoiceninja/tree/v5-develop) ## [Unreleased (daily channel)](https://github.com/invoiceninja/invoiceninja/tree/v5-develop)
- Add Cache-control: no-cache to prevent overaggressive caching of assets
## [v5.1.56-release](https://github.com/invoiceninja/invoiceninja/releases/tag/v5.1.56-release)
## Fixed: ## Fixed:
- Fix User created/updated/deleted Actvity display format - Fix User created/updated/deleted Actvity display format
- Fix for Stripe autobill / token regression - Fix for Stripe autobill / token regression
@ -9,7 +12,7 @@
- Invoice / Quote / Credit created notifications - Invoice / Quote / Credit created notifications
- Logout route - deletes all auth tokens - Logout route - deletes all auth tokens
## [v5.1.54-release](https://github.com/invoiceninja/invoiceninja/releases/tag/v5.1.50-release) ## [v5.1.54-release](https://github.com/invoiceninja/invoiceninja/releases/tag/v5.1.54-release)
## Fixed: ## Fixed:
- Fixes for e-mails, encoding & parsing invalid HTML - Fixes for e-mails, encoding & parsing invalid HTML

View File

@ -164,7 +164,7 @@ class InvoiceController extends Controller
if ($invoices->count() == 1) { if ($invoices->count() == 1) {
return response()->streamDownload(function () use ($invoices) { return response()->streamDownload(function () use ($invoices) {
echo file_get_contents($invoices->first()->pdf_file_path()); echo file_get_contents($invoices->first()->pdf_file_path());
}, basename($invoices->first()->pdf_file_path())); }, basename($invoices->first()->pdf_file_path()), ['Cache-Control:' => 'no-cache']);
//return response()->download(TempFile::path($invoices->first()->pdf_file_path()), basename($invoices->first()->pdf_file_path())); //return response()->download(TempFile::path($invoices->first()->pdf_file_path()), basename($invoices->first()->pdf_file_path()));
} }

View File

@ -78,7 +78,7 @@ class QuoteController extends Controller
if ($quotes->count() == 1) { if ($quotes->count() == 1) {
return response()->streamDownload(function () use ($invoices) { return response()->streamDownload(function () use ($invoices) {
echo file_get_contents($invoices->first()->pdf_file_path()); echo file_get_contents($invoices->first()->pdf_file_path());
}, basename($invoices->first()->pdf_file_path())); }, basename($invoices->first()->pdf_file_path()), ['Cache-Control:' => 'no-cache']);
//return response()->download(TempFile::path($invoices->first()->pdf_file_path()), basename($quotes->first()->pdf_file_path())); //return response()->download(TempFile::path($invoices->first()->pdf_file_path()), basename($quotes->first()->pdf_file_path()));
} }

View File

@ -538,7 +538,7 @@ class CreditController extends BaseController
case 'download': case 'download':
return response()->streamDownload(function () use ($credit) { return response()->streamDownload(function () use ($credit) {
echo file_get_contents($credit->pdf_file_path()); echo file_get_contents($credit->pdf_file_path());
}, basename($credit->pdf_file_path())); }, basename($credit->pdf_file_path()), ['Cache-Control:' => 'no-cache']);
//return response()->download(TempFile::path($credit->pdf_file_path()), basename($credit->pdf_file_path())); //return response()->download(TempFile::path($credit->pdf_file_path()), basename($credit->pdf_file_path()));
break; break;
case 'archive': case 'archive':
@ -589,7 +589,7 @@ class CreditController extends BaseController
$file_path = $credit->service()->getCreditPdf($invitation); $file_path = $credit->service()->getCreditPdf($invitation);
return response()->download($file_path); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache']);
} }
/** /**

View File

@ -673,7 +673,7 @@ class InvoiceController extends BaseController
case 'download': case 'download':
return response()->streamDownload(function () use ($invoice) { return response()->streamDownload(function () use ($invoice) {
echo file_get_contents($invoice->pdf_file_path()); echo file_get_contents($invoice->pdf_file_path());
}, basename($invoice->pdf_file_path())); }, basename($invoice->pdf_file_path()), ['Cache-Control:' => 'no-cache']);
//return response()->download(TempFile::path($invoice->pdf_file_path()), basename($invoice->pdf_file_path())); //return response()->download(TempFile::path($invoice->pdf_file_path()), basename($invoice->pdf_file_path()));
break; break;
case 'restore': case 'restore':
@ -795,7 +795,7 @@ class InvoiceController extends BaseController
$file_path = $invoice->service()->getInvoicePdf($contact); $file_path = $invoice->service()->getInvoicePdf($contact);
return response()->download($file_path, basename($file_path)); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache']);
} }
/** /**
@ -850,7 +850,7 @@ class InvoiceController extends BaseController
$file = public_path("storage/{$file_path}"); $file = public_path("storage/{$file_path}");
return response()->download($file, basename($file)); return response()->download($file, basename($file), ['Cache-Control:' => 'no-cache']);
} catch (\Exception $e) { } catch (\Exception $e) {
return response(['message' => 'Oops, something went wrong. Make sure you have symlink to storage/ in public/ directory.'], 500); return response(['message' => 'Oops, something went wrong. Make sure you have symlink to storage/ in public/ directory.'], 500);
} }

View File

@ -142,7 +142,7 @@ class PreviewController extends BaseController
//else //else
$file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company()); $file_path = PreviewPdf::dispatchNow($maker->getCompiledHTML(true), auth()->user()->company());
return response()->download($file_path)->deleteFileAfterSend(true); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache'])->deleteFileAfterSend(true);
} }
return $this->blankEntity(); return $this->blankEntity();

View File

@ -677,7 +677,7 @@ class QuoteController extends BaseController
case 'download': case 'download':
return response()->streamDownload(function () use ($quote) { return response()->streamDownload(function () use ($quote) {
echo file_get_contents($quote->pdf_file_path()); echo file_get_contents($quote->pdf_file_path());
}, basename($quote->pdf_file_path())); }, basename($quote->pdf_file_path()), ['Cache-Control:' => 'no-cache']);
//return response()->download(TempFile::path($quote->pdf_file_path()), basename($quote->pdf_file_path())); //return response()->download(TempFile::path($quote->pdf_file_path()), basename($quote->pdf_file_path()));
break; break;
case 'restore': case 'restore':
@ -730,7 +730,7 @@ class QuoteController extends BaseController
$file_path = $quote->service()->getQuotePdf($contact); $file_path = $quote->service()->getQuotePdf($contact);
return response()->download($file_path); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache']);
} }
/** /**

View File

@ -490,7 +490,7 @@ class RecurringInvoiceController extends BaseController
$file_path = $recurring_invoice->service()->getInvoicePdf($contact); $file_path = $recurring_invoice->service()->getInvoicePdf($contact);
return response()->download($file_path, basename($file_path)); return response()->download($file_path, basename($file_path), ['Cache-Control:' => 'no-cache']);
} }
/** /**