Configurable Cache-Control for Generated PDFs in Cloud Storage
Is your feature request related to a problem? Please describe.
It would be great to have the ability to configure the Cache-Control header for the PDF files generated and uploaded by the PDFPlum extension. Currently, the extension does not offer a way to set or remove this header when uploading PDFs to Firebase Storage.
Describe the solution you'd like
Introduce a new configuration parameter, such as CACHE_CONTROL_HEADER, that allows developers to specify the desired Cache-Control behavior for the uploaded PDFs.
If left empty, the default behavior (as determined by Firebase/Google Cloud Storage) would apply.
Otherwise, developers could define values like no-store, no-cache, or other caching directives based on their needs.
Describe alternatives you've considered
No response
Additional context
No response
Changing the function "storePDF" with metadata: {cacheControl: 'no-cache'}, or "no-store", is not saved within the object metadata. Hence, the cache is still up and running.
export async function storePdf({
outputStorageBucket,
outputStoragePrefix,
outputFileName,
pdf,
}: Parameters): Promise<{
location: string | undefined;
publicUrl: string | undefined;
}> {
let publicUrl: string | undefined;
const location = path.join(outputStoragePrefix ?? "", outputFileName);
if (outputStorageBucket != null && outputStorageBucket != "") {
const bucket = getStorage().bucket(outputStorageBucket);
const file = bucket.file(location);
await file.save(pdf, {
resumable: false,
metadata: {cacheControl: 'no-cache'}, // <- Non working Edit
public:
extensionParameters.SHOULD_MAKE_PDF_PUBLIC.toLowerCase() === "yes",
}
);
publicUrl = file.publicUrl();
return { location, publicUrl };
} else {
return { location: undefined, publicUrl: undefined };
}
}
Thanks for preparing this suggestion!
Is it possible to achieve this with separate calls to Firebase API? Wouldn't it be more aligned with the separation of concerns to let it out of the responsibilities of pdfplum?